Opened 19 years ago
Closed 19 years ago
#2629 closed enhancement (fixed)
[patch] permission_required for auth.decorators
| Reported by: | 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)
Change History (2)
by , 19 years ago
| Attachment: | auth-decorator-permission-required.diff added |
|---|
comment:1 by , 19 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
(In [3779]) Fixed #2629 -- Added a permission_required decorator to
django.contrib.auth.decorator. Thanks, dummy@….