Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reverted parts of r16963 to fix a regression on the creation of permi…

…ssions on proxy models. Refs #17904. Thanks koenb for the report and claudep for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17776 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e78d6b406bede7c021aaecf7ae2c8c893e0ea84a 1 parent a8d0fc1
Aymeric Augustin authored March 22, 2012
4  django/contrib/auth/management/__init__.py
@@ -31,8 +31,8 @@ def create_permissions(app, created_models, verbosity, **kwargs):
31 31
     searched_perms = list()
32 32
     # The codenames and ctypes that should exist.
33 33
     ctypes = set()
34  
-    ctypes_for_models = ContentType.objects.get_for_models(*app_models)
35  
-    for klass, ctype in ctypes_for_models.iteritems():
  34
+    for klass in app_models:
  35
+        ctype = ContentType.objects.get_for_model(klass)
36 36
         ctypes.add(ctype)
37 37
         for perm in _get_all_permissions(klass._meta):
38 38
             searched_perms.append((ctype, perm))
5  tests/modeltests/proxy_models/models.py
@@ -44,6 +44,9 @@ class MyPerson(Person):
44 44
     class Meta:
45 45
         proxy = True
46 46
         ordering = ["name"]
  47
+        permissions = (
  48
+            ("display_users", "May display users information"),
  49
+        )
47 50
 
48 51
     objects = SubManager()
49 52
     other = PersonManager()
@@ -158,4 +161,4 @@ class Improvement(Issue):
158 161
 
159 162
 class ProxyImprovement(Improvement):
160 163
     class Meta:
161  
-        proxy = True
  164
+        proxy = True
7  tests/modeltests/proxy_models/tests.py
@@ -167,6 +167,13 @@ def test_otherperson_manager(self):
167 167
         resp = [p.name for p in OtherPerson._default_manager.all()]
168 168
         self.assertEqual(resp, ['barney', 'wilma'])
169 169
 
  170
+    def test_permissions_created(self):
  171
+        from django.contrib.auth.models import Permission
  172
+        try:
  173
+            Permission.objects.get(name="May display users information")
  174
+        except Permission.DoesNotExist:
  175
+            self.fail("The permission 'May display users information' has not been created")
  176
+
170 177
     def test_proxy_model_signals(self):
171 178
         """
172 179
         Test save signals for proxy models

0 notes on commit e78d6b4

Please sign in to comment.
Something went wrong with that request. Please try again.