filter all apis of organization city & province - cant remove own user or organoization

This commit is contained in:
2025-10-27 11:21:29 +03:30
parent 96cbd5a475
commit f567110286
9 changed files with 172 additions and 95 deletions

View File

@@ -19,6 +19,7 @@ from apps.authorization.models import (
UserRelations,
Page
)
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
@@ -118,7 +119,7 @@ class PermissionViewSet(SoftDeleteMixin, viewsets.ModelViewSet):
return Response(serializer.data)
class UserRelationViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
class UserRelationViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
""" Crud Operations for User Relations """
queryset = UserRelations.objects.all()
@@ -130,6 +131,8 @@ class UserRelationViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchM
'user__phone',
'user__national_code',
'user__province__name',
'user__unit_name',
'user__unit_national_id',
'user__city__name',
'role__name'
]
@@ -138,7 +141,7 @@ class UserRelationViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchM
role_param = self.request.query_params.get('role') # noqa
if role_param != '':
queryset = self.queryset.filter(role_id=int(role_param))
queryset = self.get_queryset().filter(role_id=int(role_param))
else:
queryset = self.get_queryset().order_by('-create_date')