mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Fixed #2629 -- Added a permission_required decorator to
django.contrib.auth.decorator. Thanks, dummy@habmalnefrage.de. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3779 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -26,3 +26,11 @@ login_required.__doc__ = (
|
||||
to the log-in page if necessary.
|
||||
"""
|
||||
)
|
||||
|
||||
def permission_required(perm, login_url=LOGIN_URL):
|
||||
"""
|
||||
Decorator for views that checks if a user has a particular permission
|
||||
enabled, redirectiing to the log-in page if necessary.
|
||||
"""
|
||||
return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user