Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from django_roles_access.tools import check_access_by_role, get_no_access_response
class RolesMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if not check_access_by_role(request):
return get_no_access_response()
response = self.get_response(request)
# Only useful for unit test.
response.django_roles = True
return response