Opened 3 years ago

Last modified 2 years ago

#17904 new Bug

Custom permissions on proxy model no longer created

Reported by: koenb 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 claudep 3 years ago.
Revert optimization of r16963

Download all attachments as: .zip

Change History (9)

comment:1 Changed 3 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

The refactoring mentioned is r16963.

comment:2 Changed 3 years ago by ramiro

  • Version changed from 1.3 to SVN

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

comment:3 Changed 3 years ago by charettes

  • Cc charette.s@… added

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

Changed 3 years ago by claudep

Revert optimization of r16963

comment:4 Changed 3 years ago by claudep

  • 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 3 years ago by aaugustin

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 3 years ago by aaugustin

  • Has patch unset
  • Severity changed from Release blocker to Normal

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

comment:7 Changed 3 years ago by charettes

  • 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 2 years ago by timo

  • Needs documentation set

Pull request was closed indicating this needs docs.

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