fix - change get_queryset flag
This commit is contained in:
@@ -256,7 +256,11 @@ class OrganizationViewSet(BaseViewSet, SoftDeleteMixin, ModelViewSet, DynamicSea
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
""" all organization """
|
||||
queryset = self.get_queryset(visibility_by_org_scope=True)
|
||||
org = get_organization_by_user(request.user)
|
||||
|
||||
queryset = self.get_queryset(
|
||||
visibility_by_org_scope=True
|
||||
) if org.free_visibility_by_scope else self.get_queryset()
|
||||
|
||||
query = self.filter_query(queryset)
|
||||
|
||||
|
||||
@@ -224,7 +224,8 @@ class OrganizationSerializer(serializers.ModelSerializer):
|
||||
'parent_organization',
|
||||
'national_unique_id',
|
||||
'company_code',
|
||||
'field_of_activity'
|
||||
'field_of_activity',
|
||||
'free_visibility_by_scope'
|
||||
]
|
||||
extra_kwargs = {}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ from apps.core.api import BaseViewSet
|
||||
from apps.core.exceptions import ConflictException
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||
from common.helpers import get_organization_by_user
|
||||
|
||||
|
||||
class RoleViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet):
|
||||
@@ -164,10 +165,16 @@ class UserRelationViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, D
|
||||
def list(self, request, *args, **kwargs):
|
||||
role_param = self.request.query_params.get('role') # noqa
|
||||
|
||||
org = get_organization_by_user(request.user)
|
||||
|
||||
queryset = self.get_queryset(
|
||||
visibility_by_org_scope=True
|
||||
) if org.free_visibility_by_scope else self.get_queryset()
|
||||
|
||||
if role_param != '':
|
||||
queryset = self.get_queryset(visibility_by_org_scope=True).filter(role_id=int(role_param))
|
||||
queryset = queryset.filter(role_id=int(role_param))
|
||||
else:
|
||||
queryset = self.get_queryset(visibility_by_org_scope=True).order_by('-create_date')
|
||||
queryset = queryset.order_by('-create_date')
|
||||
|
||||
queryset = self.filter_queryset(queryset) # noqa
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ 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 and org.free_visibility_by_scope:
|
||||
if visibility_by_org_scope:
|
||||
""" if organization has free visibility by scope, apply visibility filter """
|
||||
queryset = apply_visibility_filter(queryset, org)
|
||||
return queryset
|
||||
|
||||
@@ -6,6 +6,7 @@ from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework.response import Response
|
||||
|
||||
from apps.core.api import BaseViewSet
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||
from apps.core.pagination import CustomPageNumberPagination
|
||||
@@ -28,7 +29,7 @@ def delete(queryset, pk):
|
||||
obj.delete()
|
||||
|
||||
|
||||
class QuotaDistributionViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
class QuotaDistributionViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" quota distribution apis """
|
||||
|
||||
queryset = product_models.QuotaDistribution.objects.all()
|
||||
@@ -94,7 +95,8 @@ class QuotaDistributionViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSe
|
||||
def my_distributions(self, request):
|
||||
""" list of my distributions """
|
||||
|
||||
queryset = self.filter_query(self.queryset) # return by search param or all objects
|
||||
queryset = self.filter_query(
|
||||
self.get_queryset(visibility_by_org_scope=True)) # return by search param or all objects
|
||||
organization = get_organization_by_user(request.user)
|
||||
|
||||
query = self.request.query_params
|
||||
|
||||
@@ -672,3 +672,7 @@ AssertionError: .validate() should return the validated data
|
||||
[2025-11-02 11:53:41,310] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\api.py changed, reloading.
|
||||
[2025-11-02 11:53:43,395] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
[2025-11-02 12:01:41,047] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\core\api.py changed, reloading.
|
||||
[2025-11-02 12:01:44,122] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
[2025-11-02 12:28:52,726] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\api.py changed, reloading.
|
||||
[2025-11-02 12:28:55,700] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
[2025-11-02 12:29:03,247] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\viewsets\quota_distribution_api.py changed, reloading.
|
||||
|
||||
Reference in New Issue
Block a user