Hide keyboard shortcuts

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 functools import wraps 

 

from django_roles_access.tools import check_access_by_role, get_no_access_response 

 

 

def access_by_role(view): 

""" 

Check if logged user can access the decorated function or method. 

""" 

@wraps(view) 

def _view(request, *args, **kwargs): 

if check_access_by_role(request): 

return view(request, *args, **kwargs) 

return get_no_access_response() 

 

_view.access_by_role = True 

return _view