Opened 13 years ago
Closed 6 years ago
#17904 closed Bug (fixed)
Custom permissions on proxy model no longer created
Reported by: | Koen Biermans | Owned by: | Arthur Rio |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Normal | Keywords: | proxy contenttype permission |
Cc: | charette.s@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
I have been using some specific permissions concerning the auth user model, so I created a proxy model on user like this:
class User(auth_models.User): class Meta: proxy = True permissions = ( ("display_users", "May display users information"), ("edit_users", "May edit users information"), )
In 1.3 these custom permissions were created during syncdb (linked to the auth.User model).
Now I was testing my project with the 1.4 RC, and it turns out those permissions are no longer created.
This is caused by the refactor of the create_permissions code, which now uses get_for_models to determine the class to get the options for, but this returns the proxied class (auth.User), not the proxy class, so my custom permissions are not found and not created.
Attachments (1)
Change History (14)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 13 years ago
Version: | 1.3 → SVN |
---|
comment:3 by , 13 years ago
Cc: | added |
---|
comment:4 by , 13 years ago
Has patch: | set |
---|
comment:6 by , 13 years ago
Has patch: | unset |
---|---|
Severity: | Release blocker → Normal |
I'm leaving this ticket open so we remember to reactivate this optimization, once the situation with proxy models is improved.
comment:7 by , 13 years ago
Has patch: | set |
---|---|
Keywords: | proxy contenttype permission added |
Now that #18399 is fixed, I created a pull request that brings back the get_for_models
permission creation optimization while passing the test added in r17776. Note that this patch fixes #11154 at the same time so it includes an extra test.
comment:8 by , 11 years ago
Needs documentation: | set |
---|
Pull request was closed indicating this needs docs.
comment:9 by , 9 years ago
A newer pull request was closed as the submitter couldn't address the security concerns raised there. Someone else is welcome to follow up and try to address them.
comment:10 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I'm going to try to address the security concerns in a new pull request.
comment:11 by , 6 years ago
Needs documentation: | unset |
---|
comment:12 by , 6 years ago
Patch needs improvement: | set |
---|
comment:13 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This ticket is fixed but it was kept open to restore the optimization of f04af7080b12744c8f06fb8228ef683d556690d0 (using ContentType.objects.get_for_models()
). PR 10381 doesn't restore the optimization although it's been linked to this ticket. I tried using get_for_models()
in that patch, but it doesn't work anymore because create_permissions()
now uses model states (which don't have custom methods). Here's the error:
File "/home/tim/code/django/django/contrib/contenttypes/models.py", line 89, in get_for_models opts_models = needed_opts.pop(ct.model_class()._meta, []) AttributeError: 'ContentType' object has no attribute 'model_class'
If someone wants to look at that optimization again, please open a new ticket.
The refactoring mentioned is r16963.