From 2d17a15f3cc782f5c4cc13ff25031842428ebc86 Mon Sep 17 00:00:00 2001 From: Andrey Rusakov Date: Wed, 6 Nov 2024 11:20:16 +0100 Subject: [PATCH] Add download_guid field to the OrderItem and prepare migration --- api/models.py | 1 + api/tests/test_response_file.py | 4 ++-- api/views.py | 2 +- urls.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/models.py b/api/models.py index 80a4f1f8..77070658 100644 --- a/api/models.py +++ b/api/models.py @@ -857,6 +857,7 @@ class OrderItemStatus(models.TextChoices): ) comment = models.TextField(_("comment"), null=True, blank=True) token = models.CharField(_("token"), max_length=256, null=True, blank=True) + download_guid = models.UUIDField(_("download_guid"), null=True, blank=True) class Meta: db_table = "order_item" diff --git a/api/tests/test_response_file.py b/api/tests/test_response_file.py index 8cd6777b..db791d3b 100644 --- a/api/tests/test_response_file.py +++ b/api/tests/test_response_file.py @@ -66,12 +66,12 @@ def setUp(self): obj = self.addOrder({"title": "Order with tokened items"}) items = obj.items.all() item = OrderItem.objects.get(id=items[0].id) - item.token = ITEM_EXISTS_UUID + item.download_guid = ITEM_EXISTS_UUID item.extract_result.name = "another_demo_file" item.save() item = OrderItem.objects.get(id=items[1].id) - item.token = ITEM_FILE_NOTFOUND_UUID + item.download_guid = ITEM_FILE_NOTFOUND_UUID item.extract_result.name = "missing_another_demo_file" item.save() diff --git a/api/views.py b/api/views.py index ea502dfa..a4215fe1 100644 --- a/api/views.py +++ b/api/views.py @@ -598,7 +598,7 @@ class DownloadView(generics.RetrieveAPIView): def get(self, request, guid): queryset = Order.objects.filter(download_guid=guid) if not len(queryset): - queryset = OrderItem.objects.filter(token=guid) + queryset = OrderItem.objects.filter(download_guid=guid) if not len(queryset): return Response( {"detail": _("No object matches given id")}, status=status.HTTP_404_NOT_FOUND) diff --git a/urls.py b/urls.py index 440bd03f..232854c0 100644 --- a/urls.py +++ b/urls.py @@ -84,7 +84,7 @@ path(f'{ROOTURL}token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), path(f'{ROOTURL}token/verify/', TokenVerifyView.as_view(), name='token_verify'), path(f'{ROOTURL}session-auth/', include('rest_framework.urls', namespace='rest_framework')), - path(f'{ROOTURL}validate/orderitem/', + re_path(rf'^{ROOTURL}validate/orderitem/(?P[a-zA-Z0-9_-]+)$', views.OrderItemByTokenView.as_view(), name='orderitem_validate'), path(f'{ROOTURL}admin/', admin.site.urls, name='admin'), path(f'{ROOTURL}', include(router.urls)),