mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
[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 /)
git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@3716 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ea2a514f5c
commit
aef05822d0
@ -143,15 +143,15 @@ class MultipleObjSelectField(forms.SelectField):
|
|||||||
return '\n'.join(output)
|
return '\n'.join(output)
|
||||||
|
|
||||||
def returnObject(data):
|
def returnObject(data):
|
||||||
data = data.split('-')
|
data = data.split('/')
|
||||||
ct = ContentType.objects.get(model__exact=data[0])
|
ct = ContentType.objects.get(app_label__exact=data[0], model__exact=data[1])
|
||||||
obj = ct.get_object_for_this_type(pk=data[1])
|
obj = ct.get_object_for_this_type(pk=data[2])
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def returnKey(obj, ct=None):
|
def returnKey(obj, ct=None):
|
||||||
if not ct:
|
if not ct:
|
||||||
ct = ContentType.objects.get_for_model(obj.__class__)
|
ct = ContentType.objects.get_for_model(obj.__class__)
|
||||||
return ct.model+"-"+str(obj.id)
|
return ct.app_label+"/"+ct.model+"/"+str(obj.id)
|
||||||
|
|
||||||
returnObject = staticmethod(returnObject)
|
returnObject = staticmethod(returnObject)
|
||||||
returnKey = staticmethod(returnKey)
|
returnKey = staticmethod(returnKey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user