fix - quota exception in distribution limit & sale licence and visibility free by org
This commit is contained in:
@@ -2,6 +2,7 @@ from rest_framework import viewsets
|
||||
|
||||
from apps.authentication.mixins.region_filter import RegionFilterMixin, get_organization_by_user
|
||||
from apps.authentication.services.service import get_all_org_child
|
||||
from apps.authentication.services.visibility_services import apply_visibility_filter
|
||||
from apps.authorization.services.role_child import get_all_role_child
|
||||
from apps.core.models import MobileTest, SystemConfig
|
||||
from apps.core.serializers import MobileTestSerializer, SystemConfigSerializer
|
||||
@@ -13,7 +14,7 @@ class BaseViewSet(RegionFilterMixin, viewsets.ModelViewSet):
|
||||
It applies region-based filtering automatically to GET (list) requests.
|
||||
"""
|
||||
|
||||
def get_queryset(self, show_my_org: bool = None):
|
||||
def get_queryset(self, show_my_org: bool = None, visibility_by_org_scope: bool = None):
|
||||
queryset = super().get_queryset()
|
||||
request = self.request
|
||||
user = request.user
|
||||
@@ -23,6 +24,11 @@ class BaseViewSet(RegionFilterMixin, viewsets.ModelViewSet):
|
||||
if self.request.method.lower() == 'get' and not self.kwargs.get('pk'):
|
||||
queryset = self.filter_by_region(queryset, org=True)
|
||||
|
||||
if visibility_by_org_scope:
|
||||
""" if organization has free visibility by scope, apply visibility filter """
|
||||
queryset = apply_visibility_filter(queryset, org)
|
||||
return queryset
|
||||
|
||||
if user_relation.exists():
|
||||
user_relation = user_relation.first()
|
||||
if not user_relation.role.type.key == 'ADM':
|
||||
|
||||
Reference in New Issue
Block a user