Features: 1) Use uuid.UUID for decoding encoded UUIDs to ensure proper handling of byte data;
Fixes: 1) Remove deprecated `force_str` usage for decoding encoded UUIDs; Extra: 1) Add missing `uuid` module import; 2) Minor code cleanup in `core/views.py`.
This commit is contained in:
parent
5d9cd47e72
commit
5d8f528dfd
1 changed files with 5 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
import uuid as uuid_module
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from django.contrib.sitemaps.views import index as _sitemap_index_view
|
from django.contrib.sitemaps.views import index as _sitemap_index_view
|
||||||
|
|
@ -8,7 +9,6 @@ from django.core.cache import cache
|
||||||
from django.core.exceptions import BadRequest
|
from django.core.exceptions import BadRequest
|
||||||
from django.http import FileResponse, Http404, JsonResponse
|
from django.http import FileResponse, Http404, JsonResponse
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.utils.encoding import force_str
|
|
||||||
from django.utils.http import urlsafe_base64_decode
|
from django.utils.http import urlsafe_base64_decode
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.decorators.cache import cache_page
|
from django.views.decorators.cache import cache_page
|
||||||
|
|
@ -468,7 +468,10 @@ def download_digital_asset_view(request, *args, **kwargs):
|
||||||
a JsonResponse with an error message if an error occurs during the process.
|
a JsonResponse with an error message if an error occurs during the process.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
uuid = force_str(urlsafe_base64_decode(str(kwargs.get("encoded_uuid"))))
|
|
||||||
|
uuid_bytes = urlsafe_base64_decode(str(kwargs.get("encoded_uuid")))
|
||||||
|
uuid = str(uuid_module.UUID(bytes=uuid_bytes))
|
||||||
|
|
||||||
download = DigitalAssetDownload.objects.get(order_product__uuid=uuid)
|
download = DigitalAssetDownload.objects.get(order_product__uuid=uuid)
|
||||||
|
|
||||||
if download.num_downloads >= 1:
|
if download.num_downloads >= 1:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue