Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/django/contrib/admin/views/decorators.py: 73%
7 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1from django.contrib.auth import REDIRECT_FIELD_NAME
2from django.contrib.auth.decorators import user_passes_test
5def staff_member_required(
6 view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url="admin:login"
7):
8 """
9 Decorator for views that checks that the user is logged in and is a staff
10 member, redirecting to the login page if necessary.
11 """
12 actual_decorator = user_passes_test( 12 ↛ exitline 12 didn't jump to the function exit
13 lambda u: u.is_active and u.is_staff,
14 login_url=login_url,
15 redirect_field_name=redirect_field_name,
16 )
17 if view_func: 17 ↛ 19line 17 didn't jump to line 19, because the condition on line 17 was never false
18 return actual_decorator(view_func)
19 return actual_decorator