Commits

Diego Búrigo Zacarão committed 468de78

Added support for custom commit messages

  • Participants
  • Parent commits ba23ca4

Comments (0)

Files changed (4)

File projects/views.py

                                        "component file filter"))
                 return HttpResponseRedirect(reverse('projects.views.component_detail', 
                                 args=(project_slug, component_slug,)))
+
+            if not request.POST['message']:
+                request.user.message_set.create(message=
+                    _("Enter a message for the commit"))
+                return HttpResponseRedirect(reverse('projects.views.component_detail', 
+                                args=(project_slug, component_slug,)))
+
         # Adding extra field to the instance
         request.FILES['submited_file'].targetfile = filename
 
         try:
             postats = POFile.objects.get(filename=filename,
                                          object_id=component.id)
-            lang_name = postats.language.name
             lang_code = postats.language.code
         except (POFile.DoesNotExist, AttributeError):
             postats = None
-            lang_name = filename
             lang_code = component.trans.guess_language(filename)
 
-        # TODO: put it somewhere else using the settings.py
-        msg=_("Sending translation for %s") % lang_name
+        msg = settings.DVCS_SUBMIT_MSG % {'message': request.POST['message'],
+                                          'domain' : request.get_host()}
 
         try:
 

File templates/projects/component_submit_new_file.html

     <td><p class="fieldp"><input type="text" class="" name="newtargetfile"></p></td>
     <td>{% if stats.0.filename %} <p class="helptext">{% trans "Example: " %} {{stats.0.filename}}</p>{% endif %}</td>
     </tr>
+    <tr>
+    <th>{% trans "Commit message:" %} <span class="required">*</span></th>
+    <td><p class="fieldp"><textarea id="commit_message" name="message" class="" rows="2" cols="50"></textarea></p></td>
+    <td><p class="helptext">{% trans "Example: Updates to Brazilian Portuguese translation" %}</p></td>
+    </tr>
    </tbody>
    </table>
    <p class="submit">  <input type="submit" class="i16 send_file" class="submit" size="10" value="{% trans "Send" %}"></p>

File translations/models.py

         else:
             return self.language_code.lower()
 
+    @property
+    def lang_or_code(self):
+        return self.language or self.language_code
+
     class Meta:
         unique_together = ("content_type", "object_id", "filename")
         verbose_name = _('PO file')

File translations/templates/component_submit.html

   <legend>{% trans "Submit file" %}</legend>
   <input type="file" name="submited_file">
   <input type="submit" class="i16 send_file" size="10" value="{% trans "Send" %}">
+  <input type="hidden" id="message" name="message" value="Updates to {{pofile.lang_or_code}} translation">
   {% with pofile.locks.get.owner as owner %}
     {% if pofile.locked %}
       {% ifnotequal request.user.username owner.username %}