diff options
author | kinitrupti | 2016-11-21 12:16:09 +0530 |
---|---|---|
committer | kinitrupti | 2016-11-21 12:16:09 +0530 |
commit | dbaf7af91132ff93718678f2a5b42fee3d1b6acd (patch) | |
tree | aec4d3f94c7423280499ad6264d24f586881b08f /tbc/static/admin/views/decorators.py | |
parent | 19793cdf2025bb2a4560a0718ed5d6bce175e7b8 (diff) | |
download | Python-TBC-Interface-dbaf7af91132ff93718678f2a5b42fee3d1b6acd.tar.gz Python-TBC-Interface-dbaf7af91132ff93718678f2a5b42fee3d1b6acd.tar.bz2 Python-TBC-Interface-dbaf7af91132ff93718678f2a5b42fee3d1b6acd.zip |
Admin css fixed
Diffstat (limited to 'tbc/static/admin/views/decorators.py')
-rw-r--r-- | tbc/static/admin/views/decorators.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tbc/static/admin/views/decorators.py b/tbc/static/admin/views/decorators.py new file mode 100644 index 0000000..f14570c --- /dev/null +++ b/tbc/static/admin/views/decorators.py @@ -0,0 +1,18 @@ +from django.contrib.auth import REDIRECT_FIELD_NAME +from django.contrib.auth.decorators import user_passes_test + + +def staff_member_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, + login_url='admin:login'): + """ + Decorator for views that checks that the user is logged in and is a staff + member, redirecting to the login page if necessary. + """ + actual_decorator = user_passes_test( + lambda u: u.is_active and u.is_staff, + login_url=login_url, + redirect_field_name=redirect_field_name + ) + if view_func: + return actual_decorator(view_func) + return actual_decorator |