Opened 18 years ago

Closed 18 years ago

#2629 closed enhancement (fixed)

[patch] permission_required for auth.decorators

Reported by: dummy@… Owned by: Adrian Holovaty
Component: Contrib apps Version: dev
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

Description

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@… 18 years ago.

Download all attachments as: .zip

Change History (2)

comment:1 by Malcolm Tredinnick, 18 years ago

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