Opened 7 years ago

Last modified 17 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

Description

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 7 years ago.

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by Sebastian Noack

comment:1 Changed 6 years ago by Jacob

Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Julien Phalip

Severity: Normal
Type: New feature

comment:3 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:4 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:5 Changed 17 months ago by Tim Graham

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