add: add archive api for counterparty
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from rest_framework import generics, views
|
||||
from rest_framework.response import Response
|
||||
|
||||
@@ -9,7 +11,7 @@ from core.apps.counterparty.serializers import counterparty as serializers
|
||||
|
||||
class CounterpartyListApiView(generics.ListAPIView):
|
||||
serializer_class = serializers.CounterpartyListSerializer
|
||||
queryset = Counterparty.objects.all()
|
||||
queryset = Counterparty.objects.exclude(is_archived=True)
|
||||
pagination_class = [HasRolePermission]
|
||||
required_permissions = []
|
||||
pagination_class = CustomPageNumberPagination
|
||||
@@ -32,4 +34,18 @@ class CounterpartyCreateApiView(generics.GenericAPIView):
|
||||
return Response(
|
||||
{'success': False, 'message': serializer.errors},
|
||||
status=400
|
||||
)
|
||||
|
||||
|
||||
class ArchiveCounterpartyApiView(views.APIView):
|
||||
permission_classes = [HasRolePermission]
|
||||
required_permissions = []
|
||||
|
||||
def get(self, request, id):
|
||||
counterparty = get_object_or_404(Counterparty, id=id)
|
||||
counterparty.is_archived = True
|
||||
counterparty.save()
|
||||
return Response(
|
||||
{'success': True, 'message': 'counterparty archived'},
|
||||
status=200
|
||||
)
|
||||
Reference in New Issue
Block a user