Code

Opened 8 years ago

Closed 8 years ago

#2629 closed enhancement (fixed)

[patch] permission_required for auth.decorators

Reported by: dummy@… Owned by: adrian
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: UI/UX:

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

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by dummy@…

comment:1 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.