diff options
Diffstat (limited to 'users/decorators.py')
-rw-r--r-- | users/decorators.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/users/decorators.py b/users/decorators.py index d373692..5226460 100644 --- a/users/decorators.py +++ b/users/decorators.py @@ -1,5 +1,6 @@ from functools import wraps +from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.views import redirect_to_login from django.http import HttpResponseRedirect @@ -26,3 +27,7 @@ def identity_required(function): return function(request, *args, **kwargs) return inner + + +def admin_required(function): + return user_passes_test(lambda user: user.admin)(function) |