# HG changeset patch # User Pawel Solyga # Date 1224251874 0 # Node ID 2955eff2bf947d41b4bfbc74e3ff695e87c738f4 # Parent f90f9b22751aca70202cc380bdc168cf1785ca2e 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 diff -r f90f9b22751a -r 2955eff2bf94 app/soc/models/club.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 diff -r f90f9b22751a -r 2955eff2bf94 app/soc/models/organization.py --- 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 diff -r f90f9b22751a -r 2955eff2bf94 app/soc/models/school.py --- 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 diff -r f90f9b22751a -r 2955eff2bf94 app/soc/models/sponsor.py --- 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" ', ] + +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' - diff -r f90f9b22751a -r 2955eff2bf94 app/soc/views/site/sponsor/list.py --- 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 diff -r f90f9b22751a -r 2955eff2bf94 app/soc/views/site/sponsor/profile.py --- 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) diff -r f90f9b22751a -r 2955eff2bf94 app/soc/views/sponsor/profile.py --- 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