← Back to team overview

harvest-dev team mailing list archive

[Merge] lp:~dev-nigelj/harvest/misc-fixes into lp:harvest

 

Nigel Jones has proposed merging lp:~dev-nigelj/harvest/misc-fixes into lp:harvest.

Requested reviews:
  harvest-dev (harvest-dev)
Related bugs:
  #629371 Translations don't appear for text defined in models.py
  https://bugs.launchpad.net/bugs/629371


Include fix for Bug #629371, change to lazy gettext translations within models.py so they will be translated to the desired language.
-- 
https://code.launchpad.net/~dev-nigelj/harvest/misc-fixes/+merge/34520
Your team harvest-dev is requested to review the proposed merge of lp:~dev-nigelj/harvest/misc-fixes into lp:harvest.
=== modified file 'harvest/opportunities/models.py'
--- harvest/opportunities/models.py	2010-08-13 22:15:55 +0000
+++ harvest/opportunities/models.py	2010-09-03 09:47:38 +0000
@@ -1,5 +1,5 @@
 from django.db import models
-from django.utils.translation import ugettext as _
+from django.utils.translation import ugettext as _, ugettext_lazy as _lazy
 from django.contrib.auth.models import User
 
 import datetime
@@ -9,20 +9,20 @@
 
 EXPERIENCE_CHOICES = (
     (0, ""),
-    (1, _("Easy")),
-    (2, _("Medium")),
-    (3, _("Hard")),
+    (1, _lazy("Easy")),
+    (2, _lazy("Medium")),
+    (3, _lazy("Hard")),
 )
 
 class PackageSet(models.Model):
-    name = models.SlugField(_("Name"), max_length=40)
+    name = models.SlugField(_lazy("Name"), max_length=40)
 
     def __unicode__(self):
         return self.name
 
 
 class SourcePackage(models.Model):
-    name = models.SlugField(_("Name"), max_length=70)
+    name = models.SlugField(_lazy("Name"), max_length=70)
     packagesets = models.ManyToManyField(PackageSet, null=True)
 
     class Meta:
@@ -33,20 +33,20 @@
 
 
 class OpportunityList(models.Model):
-    name = models.SlugField(_("Name"), max_length=70)
-    url = models.URLField(_("URL"), verify_exists=False)
-    description = models.TextField(_("Description"), max_length=350)
-    last_updated = models.DateTimeField(_("Last Updated"), null=True)
-    active = models.BooleanField(_("Active"), default=True)
-    featured = models.BooleanField(_("Featured"), default=False, 
-                                   help_text=_("Specially feature this list of opportunities?"))
-    explanation = models.URLField(_("Explanatory instructions"), max_length=500, null=True, 
-                                   help_text=_("Link to more instructions about this type of opportunities."),
+    name = models.SlugField(_lazy("Name"), max_length=70)
+    url = models.URLField(_lazy("URL"), verify_exists=False)
+    description = models.TextField(_lazy("Description"), max_length=350)
+    last_updated = models.DateTimeField(_lazy("Last Updated"), null=True)
+    active = models.BooleanField(_lazy("Active"), default=True)
+    featured = models.BooleanField(_lazy("Featured"), default=False, 
+                                   help_text=_lazy("Specially feature this list of opportunities?"))
+    explanation = models.URLField(_lazy("Explanatory instructions"), max_length=500, null=True, 
+                                   help_text=_lazy("Link to more instructions about this type of opportunities."),
                                    verify_exists=False)
-    commentable = models.BooleanField(_("Commentable"), default=True, 
-                                      help_text=_("Can opportunities on this list have comments?"))
-    experience = models.IntegerField(_("Required Experience"), default=0, choices=EXPERIENCE_CHOICES,
-                                     help_text=_("Level of experience required for this type of opportunities."))
+    commentable = models.BooleanField(_lazy("Commentable"), default=True, 
+                                      help_text=_lazy("Can opportunities on this list have comments?"))
+    experience = models.IntegerField(_lazy("Required Experience"), default=0, choices=EXPERIENCE_CHOICES,
+                                     help_text=_lazy("Level of experience required for this type of opportunities."))
 
     class Meta:
         ordering = ['name']
@@ -56,17 +56,17 @@
 
 
 class Opportunity(models.Model):
-    description = models.TextField(_("Description"), max_length=350)
-    url = models.URLField(_("URL"), max_length=350, verify_exists=False)
-    last_updated = models.DateTimeField(_("Last Updated"), null=True)
-    since = models.DateTimeField(_("Since"), help_text=_("On the list since"), null=True)
-    reviewed = models.BooleanField(_("Irrelevant"), default=False, blank=True)
-    applied = models.BooleanField(_("Applied"), default=False, blank=True)
+    description = models.TextField(_lazy("Description"), max_length=350)
+    url = models.URLField(_lazy("URL"), max_length=350, verify_exists=False)
+    last_updated = models.DateTimeField(_lazy("Last Updated"), null=True)
+    since = models.DateTimeField(_lazy("Since"), help_text=_lazy("On the list since"), null=True)
+    reviewed = models.BooleanField(_lazy("Irrelevant"), default=False, blank=True)
+    applied = models.BooleanField(_lazy("Applied"), default=False, blank=True)
     sourcepackage = models.ForeignKey(SourcePackage)
     opportunitylist = models.ForeignKey(OpportunityList)
-    valid = models.BooleanField(_("Valid"), default=True)
-    experience = models.IntegerField(_("Difficulty"), choices=EXPERIENCE_CHOICES, default=0,
-                                     help_text=_("Level of experience required for this specific opportunity."))
+    valid = models.BooleanField(_lazy("Valid"), default=True)
+    experience = models.IntegerField(_lazy("Difficulty"), choices=EXPERIENCE_CHOICES, default=0,
+                                     help_text=_lazy("Level of experience required for this specific opportunity."))
 
     class Meta:
         ordering = ['-last_updated']
@@ -81,11 +81,11 @@
         if self.experience > 0:
             summary_list.append(EXPERIENCE_CHOICES[self.experience][1])
         if self.reviewed:
-            summary_list.append(_("Irrelevant"))
+            summary_list.append(_lazy("Irrelevant"))
         if self.applied:
-            summary_list.append(_("Applied"))
+            summary_list.append(_lazy("Applied"))
         if not self.valid:
-            summary_list.append(_("Invalid"))
+            summary_list.append(_lazy("Invalid"))
         return summary_list
 
 
@@ -103,9 +103,9 @@
 
 
 class ActionLogEntry(models.Model):
-    timestamp = models.DateTimeField(_("Timestamp"))
+    timestamp = models.DateTimeField(_lazy("Timestamp"))
     who = models.ForeignKey(User)
-    action = models.TextField(_("Action"), max_length=200)
+    action = models.TextField(_lazy("Action"), max_length=200)
     opportunity = models.ForeignKey(Opportunity, blank=True)
 
 def log_action(who, action=None, opportunity=None):

=== modified file 'harvest/templates/opportunities/include/opportunity.html'
--- harvest/templates/opportunities/include/opportunity.html	2010-08-13 05:22:10 +0000
+++ harvest/templates/opportunities/include/opportunity.html	2010-09-03 09:47:38 +0000
@@ -4,7 +4,7 @@
 	<a href="{{opportunity.url}}" class="opportunity-description" target="_blank">{{ opportunity.description }}</a>
 	{% if user.is_authenticated %}
 	<span class="actions">
-		<a href="{% url opportunity_edit opportunity.id %}?next={{request.get_full_path}}" target="_blank" class="opportunity-edit-button">edit</a>
+		<a href="{% url opportunity_edit opportunity.id %}?next={{request.get_full_path}}" target="_blank" class="opportunity-edit-button">{% trans 'edit' %}</a>
 	</span>
 	{% endif %}
 	<span class="opportunity-summary">

=== modified file 'harvest/templates/opportunities/include/opportunity_details_edit.html'
--- harvest/templates/opportunities/include/opportunity_details_edit.html	2010-08-13 01:38:12 +0000
+++ harvest/templates/opportunities/include/opportunity_details_edit.html	2010-09-03 09:47:38 +0000
@@ -43,6 +43,6 @@
 	<div class="actions">
 		<input type="hidden" name="next" value="{{ next }}" />
 		<input type="submit" value="{% trans 'Apply changes' %}" />
-		<a href="{{next}}" rel="deactivate"><button>Cancel</button></a>
+		<a href="{{next}}" rel="deactivate"><button>{% trans 'Cancel' %}</button></a>
 	</div>
 </form>