diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
index 01fa524..6b237c7 100644
a
|
b
|
Creates permissions for all installed apps that need permissions.
|
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.encoding import force_unicode |
7 | 8 | |
8 | 9 | def _get_permission_codename(action, opts): |
9 | 10 | return u'%s_%s' % (action, opts.object_name.lower()) |
… |
… |
def create_permissions(app, created_models, verbosity, **kwargs):
|
25 | 26 | ctype = ContentType.objects.get_for_model(klass) |
26 | 27 | for codename, name in _get_all_permissions(klass._meta): |
27 | 28 | p, created = Permission.objects.get_or_create(codename=codename, content_type__pk=ctype.id, |
28 | | defaults={'name': name, 'content_type': ctype}) |
| 29 | defaults={'name': force_unicode(name), 'content_type': ctype}) |
29 | 30 | if created and verbosity >= 2: |
30 | 31 | print "Adding permission '%s'" % p |
31 | 32 | |
diff --git a/tests/regressiontests/auth_permissions/__init__.py b/tests/regressiontests/auth_permissions/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/regressiontests/auth_permissions/models.py b/tests/regressiontests/auth_permissions/models.py
new file mode 100644
index 0000000..4c4e005
-
|
+
|
|
| 1 | from django.utils.translation import ugettext_lazy as _ |
| 2 | from django.db import models |
| 3 | |
| 4 | class Citizen(models.Model): |
| 5 | name = models.CharField(max_length=20) |
| 6 | |
| 7 | class Meta: |
| 8 | permissions = ( |
| 9 | ('vote', _("Can vote")), |
| 10 | ) |
| 11 | |
| 12 | __test__ = {'perms_tests': """ |
| 13 | >>> from django.contrib.auth.models import Permission |
| 14 | >>> Permission.objects.filter(name="Can vote") |
| 15 | [<Permission: auth_permissions | citizen | Can vote>] |
| 16 | """ |
| 17 | } |