Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2652 closed defect (fixed)

[patch] [per-object-permissions] changing perms fails if another app has model called 'user' or 'group'

Reported by: mattimustang@… Owned by: clong
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

My application has a model called Group so editing row level perms fails because the ContentType lookup is not specific enough.

Patch below fixes it.

Index: django/contrib/admin/row_level_perm_manipulator.py
===================================================================
--- django/contrib/admin/row_level_perm_manipulator.py  (revision 3712)
+++ django/contrib/admin/row_level_perm_manipulator.py  (working copy)
@@ -144,7 +144,7 @@
         
     def returnObject(data):
         data = data.split('-')
-        ct = ContentType.objects.get(model__exact=data[0])
+        ct = ContentType.objects.get(app_label='auth', model__exact=data[0])
         obj = ct.get_object_for_this_type(pk=data[1])
         return obj
 
@@ -157,4 +157,4 @@
     returnKey = staticmethod(returnKey)
         
         
-        
\ No newline at end of file
+        

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by clong

  • Owner changed from adrian to clong

comment:2 Changed 8 years ago by clong

  • Resolution set to fixed
  • Status changed from new to closed

(In [3716]) [per-object-permissions] Fixes #2652, modified the form field to include the app label in the select field (the elements of which are now separated by a /)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.