Reverted parts of r16963 to fix a regression on the creation of permissions 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
This commit is contained in:
parent
a8d0fc1001
commit
e78d6b406b
|
@ -31,8 +31,8 @@ def create_permissions(app, created_models, verbosity, **kwargs):
|
||||||
searched_perms = list()
|
searched_perms = list()
|
||||||
# The codenames and ctypes that should exist.
|
# The codenames and ctypes that should exist.
|
||||||
ctypes = set()
|
ctypes = set()
|
||||||
ctypes_for_models = ContentType.objects.get_for_models(*app_models)
|
for klass in app_models:
|
||||||
for klass, ctype in ctypes_for_models.iteritems():
|
ctype = ContentType.objects.get_for_model(klass)
|
||||||
ctypes.add(ctype)
|
ctypes.add(ctype)
|
||||||
for perm in _get_all_permissions(klass._meta):
|
for perm in _get_all_permissions(klass._meta):
|
||||||
searched_perms.append((ctype, perm))
|
searched_perms.append((ctype, perm))
|
||||||
|
|
|
@ -44,6 +44,9 @@ class MyPerson(Person):
|
||||||
class Meta:
|
class Meta:
|
||||||
proxy = True
|
proxy = True
|
||||||
ordering = ["name"]
|
ordering = ["name"]
|
||||||
|
permissions = (
|
||||||
|
("display_users", "May display users information"),
|
||||||
|
)
|
||||||
|
|
||||||
objects = SubManager()
|
objects = SubManager()
|
||||||
other = PersonManager()
|
other = PersonManager()
|
||||||
|
|
|
@ -167,6 +167,13 @@ class ProxyModelTests(TestCase):
|
||||||
resp = [p.name for p in OtherPerson._default_manager.all()]
|
resp = [p.name for p in OtherPerson._default_manager.all()]
|
||||||
self.assertEqual(resp, ['barney', 'wilma'])
|
self.assertEqual(resp, ['barney', 'wilma'])
|
||||||
|
|
||||||
|
def test_permissions_created(self):
|
||||||
|
from django.contrib.auth.models import Permission
|
||||||
|
try:
|
||||||
|
Permission.objects.get(name="May display users information")
|
||||||
|
except Permission.DoesNotExist:
|
||||||
|
self.fail("The permission 'May display users information' has not been created")
|
||||||
|
|
||||||
def test_proxy_model_signals(self):
|
def test_proxy_model_signals(self):
|
||||||
"""
|
"""
|
||||||
Test save signals for proxy models
|
Test save signals for proxy models
|
||||||
|
|
Loading…
Reference in New Issue