fix: part of functionality has taken from ContractView to ContractRelationsViewSet
This commit is contained in:
@@ -95,7 +95,7 @@ PATCH /banks/<uuid:pk> # admin # ok
|
|||||||
|
|
||||||
|
|
||||||
GET /contracts # admin # ok
|
GET /contracts # admin # ok
|
||||||
POST /contracts # user # remake
|
POST /contracts # user # ok
|
||||||
GET /contracts/<uuid:pk> # admin # ok
|
GET /contracts/<uuid:pk> # admin # ok
|
||||||
DELETE /contracts/<uuid:pk> # admin # ok
|
DELETE /contracts/<uuid:pk> # admin # ok
|
||||||
PATCH /contracts/<uuid:pk> # admin # ok
|
PATCH /contracts/<uuid:pk> # admin # ok
|
||||||
|
|||||||
@@ -154,5 +154,3 @@ class CreateContractSerializer(BaseContractSerializer):
|
|||||||
attached_files.save() # type: ignore
|
attached_files.save() # type: ignore
|
||||||
|
|
||||||
return contract
|
return contract
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ router = DefaultRouter()
|
|||||||
|
|
||||||
router.register(r"contract-attached-files", views.ContractAttachedFileView, "contract-attached-files") # type: ignore
|
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.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-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.ContractOwnerView, "contract-owners") # type: ignore
|
||||||
router.register(r"contract-owners", views.ContractOwnerFileViewSet, "contract-owner-files") # type: ignore
|
router.register(r"contract-owners", views.ContractOwnerFileViewSet, "contract-owner-files") # type: ignore
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [ # type: ignore
|
urlpatterns = [ # type: ignore
|
||||||
path("", include(router.urls)), # type: ignore
|
path("", include(router.urls)), # type: ignore
|
||||||
path(
|
path(
|
||||||
|
|||||||
@@ -38,11 +38,9 @@ class ContractView(BaseViewSetMixin, ModelViewSet):
|
|||||||
action_permission_classes = { # type: ignore
|
action_permission_classes = { # type: ignore
|
||||||
"list": [IsAdminUser],
|
"list": [IsAdminUser],
|
||||||
"retrieve": [IsAdminUser],
|
"retrieve": [IsAdminUser],
|
||||||
"create": [IsAuthenticated],
|
"create": [AllowAny],
|
||||||
"update": [IsAdminUser],
|
"update": [IsAdminUser],
|
||||||
"destroy": [IsAdminUser],
|
"destroy": [IsAdminUser],
|
||||||
"list_file": [AllowAny],
|
|
||||||
"list_owner": [AllowAny],
|
|
||||||
}
|
}
|
||||||
action_serializer_class = { # type: ignore
|
action_serializer_class = { # type: ignore
|
||||||
"list": ListContractSerializer,
|
"list": ListContractSerializer,
|
||||||
@@ -50,8 +48,6 @@ class ContractView(BaseViewSetMixin, ModelViewSet):
|
|||||||
"create": CreateContractSerializer,
|
"create": CreateContractSerializer,
|
||||||
"update": UpdateContractSerializer,
|
"update": UpdateContractSerializer,
|
||||||
"destroy": DestroyContractSerializer,
|
"destroy": DestroyContractSerializer,
|
||||||
"list_file": ListContractAttachedFileSerializer,
|
|
||||||
"list_owner": RetrieveContractOwnerSerializer,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def create(
|
def create(
|
||||||
@@ -63,6 +59,20 @@ class ContractView(BaseViewSetMixin, ModelViewSet):
|
|||||||
#! TODO: checkout if user has access to create new contract.
|
#! TODO: checkout if user has access to create new contract.
|
||||||
return super().create(request, *args, **kwargs) # type: ignore
|
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(
|
@extend_schema(
|
||||||
summary="Get List Of Files",
|
summary="Get List Of Files",
|
||||||
description="Get List Of Files"
|
description="Get List Of Files"
|
||||||
|
|||||||
Reference in New Issue
Block a user