fix: part of functionality has taken from ContractView to ContractRelationsViewSet

This commit is contained in:
2025-08-06 09:47:41 +05:00
parent 8de652c57b
commit 59d1fe4a9a
4 changed files with 17 additions and 9 deletions

View File

@@ -95,7 +95,7 @@ PATCH /banks/<uuid:pk> # admin # ok
GET /contracts # admin # ok
POST /contracts # user # remake
POST /contracts # user # ok
GET /contracts/<uuid:pk> # admin # ok
DELETE /contracts/<uuid:pk> # admin # ok
PATCH /contracts/<uuid:pk> # admin # ok

View File

@@ -154,5 +154,3 @@ class CreateContractSerializer(BaseContractSerializer):
attached_files.save() # type: ignore
return contract

View File

@@ -7,11 +7,11 @@ router = DefaultRouter()
router.register(r"contract-attached-files", views.ContractAttachedFileView, "contract-attached-files") # type: ignore
router.register(r"contracts", views.ContractView, "contracts") # type: ignore
router.register(r"contracts", views.ContractRelationsViewSet, "contract-relations") # type: ignore
router.register(r"contract-file-contents", views.ContractFileContentView, "contract-file-contents") # type: ignore
router.register(r"contract-owners", views.ContractOwnerView, "contract-owners") # type: ignore
router.register(r"contract-owners", views.ContractOwnerFileViewSet, "contract-owner-files") # type: ignore
urlpatterns = [ # type: ignore
path("", include(router.urls)), # type: ignore
path(

View File

@@ -38,11 +38,9 @@ class ContractView(BaseViewSetMixin, ModelViewSet):
action_permission_classes = { # type: ignore
"list": [IsAdminUser],
"retrieve": [IsAdminUser],
"create": [IsAuthenticated],
"create": [AllowAny],
"update": [IsAdminUser],
"destroy": [IsAdminUser],
"list_file": [AllowAny],
"list_owner": [AllowAny],
}
action_serializer_class = { # type: ignore
"list": ListContractSerializer,
@@ -50,8 +48,6 @@ class ContractView(BaseViewSetMixin, ModelViewSet):
"create": CreateContractSerializer,
"update": UpdateContractSerializer,
"destroy": DestroyContractSerializer,
"list_file": ListContractAttachedFileSerializer,
"list_owner": RetrieveContractOwnerSerializer,
}
def create(
@@ -63,6 +59,20 @@ class ContractView(BaseViewSetMixin, ModelViewSet):
#! TODO: checkout if user has access to create new contract.
return super().create(request, *args, **kwargs) # type: ignore
class ContractRelationsViewSet(BaseViewSetMixin, ModelViewSet):
queryset = ContractModel.objects.all()
permission_classes = [AllowAny]
action_permission_classes = {
"list_file": [AllowAny],
"list_owner": [AllowAny],
}
action_serializer_class = { # type: ignore
"list_file": ListContractAttachedFileSerializer,
"list_owner": RetrieveContractOwnerSerializer,
}
@extend_schema(
summary="Get List Of Files",
description="Get List Of Files"