Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixed #11154 and #17904 -- Inconsistency with permissions for proxy models #146

Closed
wants to merge 1 commit into from

2 participants

Simon Charette Anssi Kääriäinen
Simon Charette
Owner

Make sure permissions are associated with the correct
ContentType when dealing with proxy models.

Simon Charette Fixed #11154 and #17904 -- Inconsistency with permissions for proxy m…
…odels

Make sure permissions are associated with the correct
`ContentType` when dealing with proxy models.
bb74e03
Anssi Kääriäinen
Owner

Please add release notes and reopen.

Anssi Kääriäinen akaariai closed this July 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 09, 2012
Simon Charette Fixed #11154 and #17904 -- Inconsistency with permissions for proxy m…
…odels

Make sure permissions are associated with the correct
`ContentType` when dealing with proxy models.
bb74e03
This page is out of date. Refresh to see the latest.
5  django/contrib/auth/management/__init__.py
@@ -33,8 +33,9 @@ def create_permissions(app, created_models, verbosity, **kwargs):
33 33
     searched_perms = list()
34 34
     # The codenames and ctypes that should exist.
35 35
     ctypes = set()
36  
-    for klass in app_models:
37  
-        ctype = ContentType.objects.get_for_model(klass)
  36
+    ctypes_for_models = ContentType.objects.get_for_models(*app_models,
  37
+                                                           for_concrete_models=False)
  38
+    for klass, ctype in ctypes_for_models.iteritems():
38 39
         ctypes.add(ctype)
39 40
         for perm in _get_all_permissions(klass._meta):
40 41
             searched_perms.append((ctype, perm))
5  tests/modeltests/proxy_models/tests.py
@@ -173,6 +173,11 @@ def test_permissions_created(self):
173 173
             Permission.objects.get(name="May display users information")
174 174
         except Permission.DoesNotExist:
175 175
             self.fail("The permission 'May display users information' has not been created")
  176
+        try:
  177
+            Permission.objects.get(content_type__model='myperson',
  178
+                                   codename='add_myperson')
  179
+        except Permission.DoesNotExist:
  180
+            self.fail("There's no permission 'add_myperson' associated with the MyPerson model")
176 181
 
177 182
     def test_proxy_model_signals(self):
178 183
         """
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.