From 5af11f6f2f825adf1afcd0e10f6f278b24f82c03 Mon Sep 17 00:00:00 2001 From: rup-narayan-rajbanshi Date: Fri, 27 Sep 2024 12:09:02 +0545 Subject: [PATCH] Remove rest api for buld lead delete --- apps/lead/tests/test_apis.py | 40 ------------------------------------ apps/lead/views.py | 30 +-------------------------- deep/urls.py | 3 --- 3 files changed, 1 insertion(+), 72 deletions(-) diff --git a/apps/lead/tests/test_apis.py b/apps/lead/tests/test_apis.py index 11e6aae21a..e53a747e1f 100644 --- a/apps/lead/tests/test_apis.py +++ b/apps/lead/tests/test_apis.py @@ -131,46 +131,6 @@ def test_lead_create_with_status_validated(self, assignee=None): r_data = response.data self.assertEqual(r_data['status'], data['status']) - def test_pre_bulk_delete_leads(self): - project = self.create(Project) - lead1 = self.create(Lead, project=project) - lead3 = self.create(Lead, project=project) - - lead_ids = [lead1.id, lead3.id] - admin_user = self.create(User) - project.add_member(admin_user, role=self.admin_role) - url = '/api/v1/project/{}/leads/dry-bulk-delete/'.format(project.id) - self.authenticate(admin_user) - response = self.client.post(url, {'leads': lead_ids}) - self.assert_200(response) - r_data = response.data - self.assertIn('entries', r_data) - - def test_bulk_delete_leads(self): - project = self.create(Project) - lead1 = self.create(Lead, project=project) - self.create(Lead, project=project) - lead3 = self.create(Lead, project=project) - lead_count = Lead.objects.count() - - lead_ids = [lead1.id, lead3.id] - url = '/api/v1/project/{}/leads/bulk-delete/'.format(project.id) - - # calling without delete permissions - view_user = self.create(User) - project.add_member(view_user, role=self.view_only_role) - self.authenticate(view_user) - response = self.client.post(url, {'leads': lead_ids}) - self.assert_403(response) - - admin_user = self.create(User) - project.add_member(admin_user, role=self.admin_role) - self.authenticate(admin_user) - response = self.client.post(url, {'leads': lead_ids}) - self.assert_204(response) - - self.assertLess(Lead.objects.count(), lead_count) - def test_create_high_priority_lead(self, assignee=None): lead_count = Lead.objects.count() project = self.create(Project, role=self.admin_role) diff --git a/apps/lead/views.py b/apps/lead/views.py index 339563cb9d..1e85ad6bfa 100644 --- a/apps/lead/views.py +++ b/apps/lead/views.py @@ -25,7 +25,7 @@ import django_filters -from deep.permissions import ModifyPermission, CreateLeadPermission, DeleteLeadPermission +from deep.permissions import ModifyPermission, CreateLeadPermission from deep.paginations import AutocompleteSetPagination from deep.authentication import CSRFExemptSessionAuthentication @@ -237,34 +237,6 @@ def leads_filter(self, request, version=None): return response -class LeadBulkDeleteViewSet(viewsets.GenericViewSet): - permission_classes = [permissions.IsAuthenticated, DeleteLeadPermission] - - def get_serializer_class(self): - # required by ViewSchema generator - return serializers.Serializer - - @action( - detail=False, - methods=['post'], - url_path='dry-bulk-delete', - ) - def dry_bulk_delete(self, request, project_id, version=None): - lead_ids = request.data.get('leads', []) - tbd_entities = Lead.get_associated_entities(project_id, lead_ids) - return response.Response(tbd_entities, status=status.HTTP_200_OK) - - @action( - detail=False, - methods=['post'], - url_path='bulk-delete', - ) - def bulk_delete(self, request, project_id, version=None): - lead_ids = request.data.get('leads', []) - Lead.objects.filter(project_id=project_id, id__in=lead_ids).delete() - return response.Response(status=status.HTTP_204_NO_CONTENT) - - class LeadPreviewViewSet(viewsets.ReadOnlyModelViewSet): serializer_class = LeadPreviewSerializer permission_classes = [permissions.IsAuthenticated, diff --git a/deep/urls.py b/deep/urls.py index 6a092968b3..402feebce6 100644 --- a/deep/urls.py +++ b/deep/urls.py @@ -75,7 +75,6 @@ from lead.views import ( LeadGroupViewSet, LeadViewSet, - LeadBulkDeleteViewSet, LeadPreviewViewSet, LeadOptionsView, LeadExtractionTriggerView, @@ -255,8 +254,6 @@ basename='lead_group') router.register(r'leads', LeadViewSet, basename='lead') -router.register(r'project/(?P\d+)/leads', LeadBulkDeleteViewSet, - basename='leads-bulk') router.register(r'lead-previews', LeadPreviewViewSet, basename='lead_preview')