Opened 12 years ago

Closed 12 years ago

#2629 closed enhancement (fixed)

[patch] permission_required for auth.decorators

Reported by: dummy@… Owned by: Adrian Holovaty
Component: Contrib apps Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The idea for this decorator came up when I looked the auth docs and saw complicated python code (for me:) like this:
my_view = user_passes_test(lambda u: u.has_perm('polls.can_vote'), login_url='/login/')(my_view)

As this code is for documentation purpose, I could also could rewrite it shorten and more user politely like this:
my_view = permission_required('polls.can_vote')(my_view)

Attachments (1)

auth-decorator-permission-required.diff (603 bytes) - added by dummy@… 12 years ago.

Download all attachments as: .zip

Change History (2)

Changed 12 years ago by dummy@…

comment:1 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [3779]) Fixed #2629 -- Added a permission_required decorator to
django.contrib.auth.decorator. Thanks, dummy@….

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