Skip to content

Commit

Permalink
Add download_guid field to the OrderItem and prepare migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Rusakov committed Nov 6, 2024
1 parent b0b6b0e commit 2d17a15
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions api/tests/test_response_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<uuid:token>',
re_path(rf'^{ROOTURL}validate/orderitem/(?P<token>[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)),
Expand Down

0 comments on commit 2d17a15

Please sign in to comment.