Coverage for audoma_api/permissions.py: 67%

18 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-08-04 07:22 +0000

1from rest_framework.permissions import BasePermission 

2 

3 

4class ViewAndDetailPermission(BasePermission): 

5 """The ViewAndDetailPermission guard access to all views nad detail views (collections and resources). 

6 General view permission is determined first then if it's detail view specific object permission is checked. 

7 """ 

8 

9 def has_permission(self, request, view): 

10 return True 

11 

12 def has_object_permission(self, request, view, obj): 

13 return True 

14 

15 

16class DetailPermission(BasePermission): 

17 """The DetailPermission guard access to Detail Views (resources).""" 

18 

19 def has_object_permission(self, request, view, obj): 

20 return True 

21 

22 

23class ViewPermission(BasePermission): 

24 """The ViewPermission guard access to all views in ViewSet (collections and resources).""" 

25 

26 def has_permission(self, request, view): 

27 return True 

28 

29 

30class AlternatePermission1(BasePermission): 

31 """The AlternatePermission1 is combined through OR operator with AlternatePermission2""" 

32 

33 def has_permission(self, request, view): 

34 return True 

35 

36 

37class AlternatePermission2(BasePermission): 

38 """The AlternatePermission2 is combined through OR operator with AlternatePermission1""" 

39 

40 def has_permission(self, request, view): 

41 return True 

42 

43 

44# check_object_permissions