From f4691ec7fa0d34cf6aad67ad3057b2c32d63c926 Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Tue, 5 Mar 2024 11:46:10 +0100
Subject: [PATCH] fix deletion of mimetypes import

---
 scipost_django/finances/views.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scipost_django/finances/views.py b/scipost_django/finances/views.py
index 7a641eac0..79e7c7c94 100644
--- a/scipost_django/finances/views.py
+++ b/scipost_django/finances/views.py
@@ -4,6 +4,7 @@ __license__ = "AGPL v3"
 
 import datetime
 from itertools import accumulate
+import mimetypes
 from dal import autocomplete
 
 from django.db.models import Q
@@ -542,8 +543,9 @@ def subsidy_attachment(request, subsidy_id, attachment_id):
     content_type, encoding = mimetypes.guess_type(attachment.attachment.path)
     content_type = content_type or "application/octet-stream"
     response = HttpResponse(attachment.attachment.read(), content_type=content_type)
-    response["Content-Encoding"] = encoding
-    response["Content-Disposition"] = "filename=%s" % attachment.attachment.name
+    if encoding:
+        response["Content-Encoding"] = encoding
+        response["Content-Disposition"] = "filename=%s" % attachment.attachment.name
     return response
 
 
-- 
GitLab