Bases: CommonModelViewSet
Source code in src/apps/core/views/contract_view.py
| @method_decorator(
name="list", decorator=swagger_auto_schema(operation_description="List Contracts")
)
class ContractViewSet(CommonModelViewSet):
serializer_class = ContractModelSerializer
queryset = Contract.objects.all()
filterset_class = ContractFilter
access_policy = ContractAccessPolicy
@swagger_auto_schema(
request_body=LegacyContractSerializer(),
responses={200: ContractModelSerializer(), 201: ContractModelSerializer},
)
@action(detail=False, methods=["post"], url_path="from-legacy")
def from_legacy(self, request):
contract, created = Contract.create_or_update_from_legacy(request.data)
rep = ContractModelSerializer(instance=contract).data
return Response(rep, status=201 if created else 200)
|