Opened 5 years ago

Last modified 11 months ago

#17904 new Bug

Custom permissions on proxy model no longer created

Reported by: Koen Biermans Owned by: nobody
Component: contrib.auth Version: master
Severity: Normal Keywords: proxy contenttype permission
Cc: charette.s@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
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)

17904.diff (2.2 KB) - added by Claude Paroz 5 years ago.
Revert optimization of r16963

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by Ramiro Morales

Triage Stage: UnreviewedAccepted

The refactoring mentioned is r16963.

comment:2 Changed 5 years ago by Ramiro Morales

Version: 1.3SVN

Related tickets with pending conceptual/design decision: #11154, #17648 and #14492.

comment:3 Changed 5 years ago by Simon Charette

Cc: charette.s@… added

Actually the fix provided in #17648 would fix #11154 and this ticket, #14492 is really about another issue.

Changed 5 years ago by Claude Paroz

Attachment: 17904.diff added

Revert optimization of r16963

comment:4 Changed 5 years ago by Claude Paroz

Has patch: set

Unless #17648 is fixed (proxy models having their own distinct ContentType) and we are probably too late in the 1.4 cycle for such a change, reverting the optimization of r16963 is probably the safest move at this time.

comment:5 Changed 5 years ago by Aymeric Augustin

In [17776]:

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.

comment:6 Changed 5 years ago by Aymeric Augustin

Has patch: unset
Severity: Release blockerNormal

I'm leaving this ticket open so we remember to reactivate this optimization, once the situation with proxy models is improved.

comment:7 Changed 5 years ago by Simon Charette

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 Changed 3 years ago by Tim Graham

Needs documentation: set

Pull request was closed indicating this needs docs.

comment:9 Changed 11 months ago by Tim Graham

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.

Note: See TracTickets for help on using tickets.
Back to Top