Adds an optional API field to follow the filenaming format when creating a bulk download zip

This commit is contained in:
Trenton Holmes
2022-12-08 18:32:14 -08:00
committed by Trenton H
parent ff4a8b37bd
commit 54bb1ae27d
5 changed files with 181 additions and 11 deletions
+2 -1
View File
@@ -745,6 +745,7 @@ class BulkDownloadView(GenericAPIView):
ids = serializer.validated_data.get("documents")
compression = serializer.validated_data.get("compression")
content = serializer.validated_data.get("content")
follow_filename_format = serializer.validated_data.get("follow_formatting")
os.makedirs(settings.SCRATCH_DIR, exist_ok=True)
temp = tempfile.NamedTemporaryFile(
@@ -761,7 +762,7 @@ class BulkDownloadView(GenericAPIView):
strategy_class = ArchiveOnlyStrategy
with zipfile.ZipFile(temp.name, "w", compression) as zipf:
strategy = strategy_class(zipf)
strategy = strategy_class(zipf, follow_filename_format)
for id in ids:
doc = Document.objects.get(id=id)
strategy.add_document(doc)