From 44d3960f94c9a306334252ef1e015bf717945c79 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Tue, 27 May 2025 15:38:40 +0330 Subject: [PATCH] insert , to origin list --- Rasaddam_Backend/settings.py | 2 +- apps/tag/models.py | 1 + apps/tag/web/api/v1/api.py | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Rasaddam_Backend/settings.py b/Rasaddam_Backend/settings.py index 28c985b..9983d2a 100644 --- a/Rasaddam_Backend/settings.py +++ b/Rasaddam_Backend/settings.py @@ -290,7 +290,7 @@ CORS_ALLOWED_ORIGINS = ( 'http://127.0.0.1:3000', 'http://localhost:3000', 'http://192.168.88.130:3000', - 'https://rasadyar.net' + 'https://rasadyar.net', 'https://rasaddam-front.liara.run' ) diff --git a/apps/tag/models.py b/apps/tag/models.py index 61b74b7..bae4f4c 100644 --- a/apps/tag/models.py +++ b/apps/tag/models.py @@ -71,6 +71,7 @@ class TagAssignment(BaseModel): ('A', 'Accept'), ('W', 'Waiting'), ('C', 'Cancel'), + ('E', 'Exited'), ) status = models.CharField(max_length=1, choices=status_choices, default="W") diff --git a/apps/tag/web/api/v1/api.py b/apps/tag/web/api/v1/api.py index ddf8e9a..4be8eac 100644 --- a/apps/tag/web/api/v1/api.py +++ b/apps/tag/web/api/v1/api.py @@ -166,7 +166,7 @@ class TagAssignmentViewSet(viewsets.ModelViewSet): f'tag_assignment_document_{assignment.serial}.{str(document).split(".")[1]}' ) assignment.document = document_url - assignment.status = 'A' + assignment.status = 'E' assignment.save() serializer = self.serializer_class(assignment) return Response(serializer.data, status=status.HTTP_200_OK) @@ -192,6 +192,21 @@ class TagAssignmentViewSet(viewsets.ModelViewSet): return Response(status.HTTP_200_OK) + @action( + methods=['post'], + detail=True, + url_name='remove_tags_by_id', + url_path='remove_tags_by_id', + name='remove_tags_by_id' + ) + def remove_assigned_tags_by_id(self, request, pk=None): + allocated_tag = tag_models.AllocatedTags.objects.filter(id__in=request.data['allocated_tag_ids']) + for obj in allocated_tag: + obj.tag.status = 'F' + obj.tag.save() + allocated_tag.delete() + return Response(status.HTTP_200_OK) + @action( methods=['put'], detail=True,