Opened 6 years ago

Last modified 12 months ago

#13664 new New feature

Enable admin permission checks from outside the ModelAdmin

Reported by: sebastian_noack Owned by: nobody
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


At the moment there is no clean and convinient way to check for the admin permissions of a model from outside its ModelAdmin class. But for example, when I link from one model's admin to onther models's admin changelist, It would be good pratice to check first if the logged in user has the change permission for the other model. So it would be nice if the AdminSite, which is accessible from all ModelAdmin classes has methods to check those permissions for the admin of a given model. My patch adds the has_*_permission() methods from the ModelAdmin class also to the AdminSite class. But those methods in the AdminSite class takes also a model (or a string in the form 'app_label.model_name') and forwards the call to the corresponding method on the given models's admin class.

Attachments (1)

add_permission_checks_to_admin_site.patch (1.3 KB) - added by sebastian_noack 6 years ago.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by sebastian_noack

comment:1 Changed 6 years ago by jacob

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

comment:2 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:3 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:4 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:5 Changed 12 months ago by timgraham

  • Summary changed from Enable admin permission checks from outside the ModelAdmin [PATCH] to Enable admin permission checks from outside the ModelAdmin
  • Version changed from 1.2 to master
Note: See TracTickets for help on using tickets.
Back to Top