Coverage for apps/users/mixins.py: 76%
19 statements
« prev ^ index » next coverage.py v6.4.4, created at 2024-04-19 09:45 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2024-04-19 09:45 -0600
1from rest_framework.permissions import AllowAny
3from apps.users.permissions import AdminPanel, UserPermission
6class BaseMixin:
7 @property
8 def model(self):
9 """
10 Retrieve model used in serializer
11 """
12 return self.serializer_class.Meta.model
14 @property
15 def user(self):
16 """
17 Retrieve user
18 """
19 return self.request.user
21 def get_queryset(self):
22 """
23 Get Only Organization Related objects
24 """
25 if self.queryset:
26 return self.queryset
27 return self.model.objects.all()
30class AdminMixin(BaseMixin):
31 permission_classes = [AdminPanel]
34class PublicMixin(BaseMixin):
35 permission_classes = [AllowAny]
38class UserMixin(BaseMixin):
39 permission_classes = [UserPermission]