From ac2c9706dfd7a03e36e96954c8d687c97def0912 Mon Sep 17 00:00:00 2001 From: behruz-dev Date: Wed, 3 Sep 2025 17:23:59 +0500 Subject: [PATCH] add: add counterparty delete api --- core/apps/counterparty/urls.py | 1 + core/apps/counterparty/views/counterparty.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/apps/counterparty/urls.py b/core/apps/counterparty/urls.py index 09fba52..b5cdc20 100644 --- a/core/apps/counterparty/urls.py +++ b/core/apps/counterparty/urls.py @@ -11,6 +11,7 @@ urlpatterns = [ path('create/', cp_views.CounterpartyCreateApiView.as_view()), path('/archive/', cp_views.ArchiveCounterpartyApiView.as_view()), path('archived/list/', cp_views.ArchivedCounterpartyListApiView.as_view()), + path('/delete/', cp_views.CounterpartyDeleteApiView.as_view()), ] )), path('counterparty_folder/', include( diff --git a/core/apps/counterparty/views/counterparty.py b/core/apps/counterparty/views/counterparty.py index 7f06fe5..ff2d863 100644 --- a/core/apps/counterparty/views/counterparty.py +++ b/core/apps/counterparty/views/counterparty.py @@ -56,4 +56,17 @@ class ArchivedCounterpartyListApiView(generics.ListAPIView): queryset = Counterparty.objects.exclude(is_archived=False) pagination_class = [HasRolePermission] required_permissions = [] - pagination_class = CustomPageNumberPagination \ No newline at end of file + pagination_class = CustomPageNumberPagination + + +class CounterpartyDeleteApiView(views.APIView): + permission_classes = [HasRolePermission] + required_permissions = [] + + def delete(self, request, id): + counterparty = get_object_or_404(Counterparty, id=id) + counterparty.delete() + return Response( + {'success': True, 'message': 'counterparty deleted'}, + status=204 + ) \ No newline at end of file