Corp/backend/api/v1/requests_app/attachments.py
Игорь Надеин 4f6244ab1f
Some checks failed
Deploy production / deploy (push) Failing after 2s
Fix CORP runtime errors and harden deployment and media access
2026-09-10 16:40:08 +03:00

16 lines
496 B
Python

from pathlib import PurePosixPath
from django.urls import reverse
def attachment_download_url(obj, request=None):
"""Never expose a storage URL: the download rechecks the request's ACL."""
if not obj.attachment:
return None
url = reverse("api:v1:request-attachment-download", kwargs={"pk": obj.pk})
return request.build_absolute_uri(url) if request else url
def attachment_filename(obj):
return PurePosixPath(obj.attachment.name).name if obj.attachment else None