Opened 18 years ago

Closed 17 years ago

#2104 closed enhancement (wontfix)

[patch] Make admin view methods wrappable by user views for non-staff

Reported by: garthk@… Owned by: nobody
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: gary.wilson@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm trying to call admin views from my views to greatly simplify my code. My efforts are frustrated by this style of view definition in django.contrib.admin.views.main:

def useful_view_method(request): 
   # ...
useful_view_method = staff_member_required(usefulmethod)

Thanks to the wrapper, the method is useful only to the admin interface unless I make a copy of it. Such a copy is inefficient, error-prone, and requires checking each Django code update.

Making the unprotected view available as follows would let me wrap the view myself to whatever protection level I see fit:

def _useful_view_method(request):
    # ...
useful_view_method = staff_member_required(_useful_view_method)

On a similar line of thinking: change_list needlessly insists on change permission. I'd like it to list regardless, as even mortals should be able to view the table I've got in mind. I can have my change_stage equivalent check permissions and then pass on to either a read-only view method or the "official" change_stage, at least once I can reach around the staff_member_required wrapper.

Attachments (1)

2104.diff (6.7 KB ) - added by garthk@… 18 years ago.
[patch] permit wrapping of change_list et al

Download all attachments as: .zip

Change History (10)

by garthk@…, 18 years ago

Attachment: 2104.diff added

[patch] permit wrapping of change_list et al

comment:1 by anonymous, 18 years ago

Summary: Admin view paranoia limits re-use[patch] Make admin view methods wrappable by user views for non-staff

comment:2 by Malcolm Tredinnick, 18 years ago

Type: defectenhancement

comment:3 by Jacob, 18 years ago

Resolution: fixed
Status: newclosed

(In [4577]) Fixed #2104: allow somewhat nicer error messages in RequiredIfOtherFieldEquals validator. Thanks, Steven Armstrong

comment:4 by Jacob, 18 years ago

Resolution: fixed
Status: closedreopened

Darn it, that commit was supposed to close #2014, not #2104.

Reopening.

comment:5 by garthk@…, 18 years ago

If you want to close #2014 with some code, though, feel free. :)

comment:6 by Gary Wilson <gary.wilson@…>, 18 years ago

Triage Stage: UnreviewedDesign decision needed

I think it would be nice to be able to re-use some of the admin functionality in other places. The new admin options stuff being talked about will allow you to run multiple admin interface instances and use different authorization checks, so maybe that will fix this ticket.

comment:7 by Gary Wilson <gary.wilson@…>, 18 years ago

Cc: gary.wilson@… added

comment:8 by garthk@…, 18 years ago

Control over the authorisation checks and URL would definitely help. Where is this "talked about"?

comment:9 by James Bennett, 17 years ago

Resolution: wontfix
Status: reopenedclosed

The admin views are going away, to be replaced with a much more customizable AdminSite class.

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