Ticket #11105: translate_permissions.diff
File translate_permissions.diff, 1.6 KB (added by , 16 years ago) |
---|
-
.py
old new 4 4 5 5 from django.db.models import get_models, signals 6 6 from django.contrib.auth import models as auth_app 7 from django.utils.translation import ugettext as _ 8 from django.utils.encoding import force_unicode 9 7 10 8 11 def _get_permission_codename(action, opts): 9 12 return u'%s_%s' % (action, opts.object_name.lower()) … … 11 14 def _get_all_permissions(opts): 12 15 "Returns (codename, name) for all permissions in the given opts." 13 16 perms = [] 14 for action in ('add', 'change', 'delete'): 15 perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw))) 17 default_actions = ( 18 ('add', _(u'Can add %(name)s') % {'name': opts.verbose_name_raw}), 19 ('change', _(u'Can change %(name)s') % {'name': opts.verbose_name_raw}), 20 ('delete', _(u'Can delete %(name)s') % {'name': opts.verbose_name_raw}), 21 ) 22 for action, name in default_actions: 23 perms.append((_get_permission_codename(action, opts), 24 force_unicode(name))) 16 25 return perms + list(opts.permissions) 17 26 18 27 def create_permissions(app, created_models, verbosity, **kwargs): 19 28 from django.contrib.contenttypes.models import ContentType 20 29 from django.contrib.auth.models import Permission 30 from django.utils.translation import activate 31 from django.conf import settings 32 activate(settings.LANGUAGE_CODE) 21 33 app_models = get_models(app) 22 34 if not app_models: 23 35 return