Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Fri, 17 Oct 2008 13:57:54 +0000
changeset 369 2955eff2bf94
parent 368 f90f9b22751a
child 370 36d367e741e2
Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views. Patch by: Pawel Solyga Review by: to-be-reviewed
app/soc/models/club.py
app/soc/models/organization.py
app/soc/models/school.py
app/soc/models/sponsor.py
app/soc/views/site/sponsor/list.py
app/soc/views/site/sponsor/profile.py
app/soc/views/sponsor/profile.py
--- a/app/soc/models/club.py	Fri Oct 17 13:04:51 2008 +0000
+++ b/app/soc/models/club.py	Fri Oct 17 13:57:54 2008 +0000
@@ -21,6 +21,8 @@
 ]
 
 
+from django.utils.translation import ugettext_lazy
+
 from google.appengine.ext import db
 
 from soc.models import base
@@ -41,8 +43,9 @@
      Member model 'club' reference.
   """
 
-  #: Group type short name used for example in urls
-  GROUP_TYPE_SHORT = 'club'
-  #: Group type plural name used in Group templates
-  GROUP_TYPE_PLURAL = 'Clubs'
-
+  #: Type name used in templates
+  TYPE_NAME = ugettext_lazy('Club')
+  #: Type short name used for example in urls
+  TYPE_NAME_SHORT = 'club'
+  #: Type plural name used in templates
+  TYPE_NAME_PLURAL = ugettext_lazy('Clubs')
\ No newline at end of file
--- a/app/soc/models/organization.py	Fri Oct 17 13:04:51 2008 +0000
+++ b/app/soc/models/organization.py	Fri Oct 17 13:57:54 2008 +0000
@@ -21,6 +21,8 @@
 ]
 
 
+from django.utils.translation import ugettext_lazy
+
 from google.appengine.ext import db
 
 from soc import models
@@ -40,7 +42,9 @@
      reference.
   """
 
-  #: Group type short name used for example in urls
-  GROUP_TYPE_SHORT = 'org'
-  #: Group type plural name used in Group templates
-  GROUP_TYPE_PLURAL = 'Organizations'
\ No newline at end of file
+  #: Type name used in templates
+  TYPE_NAME = ugettext_lazy('Organization')
+  #: Type short name used for example in urls
+  TYPE_NAME_SHORT = 'org'
+  #: Type plural name used in templates
+  TYPE_NAME_PLURAL = ugettext_lazy('Organizations')
\ No newline at end of file
--- a/app/soc/models/school.py	Fri Oct 17 13:04:51 2008 +0000
+++ b/app/soc/models/school.py	Fri Oct 17 13:57:54 2008 +0000
@@ -21,6 +21,8 @@
 ]
 
 
+from django.utils.translation import ugettext_lazy
+
 from google.appengine.ext import db
 
 from soc.models import base
@@ -40,9 +42,10 @@
      belonging to) a School.  This relation is implemented as the 'students'
      back-reference Query of the Student model 'school' reference.
   """
-
-  #: Group type short name used for example in urls
-  GROUP_TYPE_SHORT = 'school'
-  #: Group type plural name used in Group templates
-  GROUP_TYPE_PLURAL = 'Schools'
-
+  
+  #: Type name used in templates
+  TYPE_NAME = ugettext_lazy('School')
+  #: Type short name used for example in urls
+  TYPE_NAME_SHORT = 'school'
+  #: Type plural name used in templates
+  TYPE_NAME_PLURAL = ugettext_lazy('Schools')
\ No newline at end of file
--- a/app/soc/models/sponsor.py	Fri Oct 17 13:04:51 2008 +0000
+++ b/app/soc/models/sponsor.py	Fri Oct 17 13:57:54 2008 +0000
@@ -20,6 +20,9 @@
   '"Pawel Solyga" <pawel.solyga@gmail.com>',
 ]
 
+
+from django.utils.translation import ugettext_lazy
+
 from google.appengine.ext import db
 
 from soc import models
@@ -29,9 +32,11 @@
 
 class Sponsor(soc.models.group.Group):
   """Sponsor details."""
+  
+  #: Type name used in templates
+  TYPE_NAME = ugettext_lazy('Sponsor')
+  #: Type short name used for example in urls
+  TYPE_NAME_SHORT = 'sponsor'
+  #: Type plural name used in templates
+  TYPE_NAME_PLURAL = ugettext_lazy('Sponsors')
 
-  #: Group type short name used for example in urls
-  GROUP_TYPE_SHORT = 'sponsor'
-  #: Group type plural name used in Group templates
-  GROUP_TYPE_PLURAL = 'Sponsors'
-
--- a/app/soc/views/site/sponsor/list.py	Fri Oct 17 13:04:51 2008 +0000
+++ b/app/soc/views/site/sponsor/list.py	Fri Oct 17 13:57:54 2008 +0000
@@ -78,8 +78,8 @@
                                  offset=offset, limit=limit, 
                                  list_templates=list_templates)
                                  
-  context.update({'entity_type': 'Sponsor',
-                  'entity_type_plural': sponsor_model.Sponsor.GROUP_TYPE_PLURAL,
-                  'entity_type_short': sponsor_model.Sponsor.GROUP_TYPE_SHORT})
+  context.update({'entity_type': sponsor_model.Sponsor.TYPE_NAME,
+                  'entity_type_plural': sponsor_model.Sponsor.TYPE_NAME_PLURAL,
+                  'entity_type_short': sponsor_model.Sponsor.TYPE_NAME_SHORT})
 
   return helper.responses.respond(request, template, context)
\ No newline at end of file
--- a/app/soc/views/site/sponsor/profile.py	Fri Oct 17 13:04:51 2008 +0000
+++ b/app/soc/views/site/sponsor/profile.py	Fri Oct 17 13:57:54 2008 +0000
@@ -196,8 +196,8 @@
     
   context.update({'form': sponsor_form,
                   'entity':  existing_sponsor,
-                  'entity_type': 'Sponsor',
-                  'entity_type_short': sponsor_model.Sponsor.GROUP_TYPE_SHORT})
+                  'entity_type': sponsor_model.Sponsor.TYPE_NAME,
+                  'entity_type_short': sponsor_model.Sponsor.TYPE_NAME_SHORT})
 
   return helper.responses.respond(request, template, context)
 
--- a/app/soc/views/sponsor/profile.py	Fri Oct 17 13:04:51 2008 +0000
+++ b/app/soc/views/sponsor/profile.py	Fri Oct 17 13:57:54 2008 +0000
@@ -28,6 +28,7 @@
 from soc.views.helper import decorators
 
 import soc.logic.models.sponsor
+import soc.models.sponsor as sponsor_model
 import soc.views.helper.responses
 import soc.views.helper.templates
 
@@ -63,6 +64,6 @@
       helper.templates.unescape(link_name_sponsor.description)
   
   context.update({'entity': link_name_sponsor,
-                  'entity_type': 'Sponsor'})
+                  'entity_type': sponsor_model.Sponsor.TYPE_NAME})
 
   return helper.responses.respond(request, template, context)
\ No newline at end of file