18_File_upload_in_certain_folders #21

Merged
mpeltriaux merged 8 commits from 18_File_upload_in_certain_folders into master 2021-09-17 11:08:01 +02:00
4 changed files with 16 additions and 8 deletions
Showing only changes of commit 270f9ab7d2 - Show all commits
+4 -2
View File
@@ -208,7 +208,8 @@ class CompensationDocument(AbstractDocument):
related_name="documents",
)
file = models.FileField(
upload_to=generate_document_file_upload_path
upload_to=generate_document_file_upload_path,
max_length=1000,
)
@@ -323,7 +324,8 @@ class EcoAccountDocument(AbstractDocument):
related_name="documents",
)
file = models.FileField(
upload_to=generate_document_file_upload_path
upload_to=generate_document_file_upload_path,
max_length=1000,
)
+2 -1
View File
@@ -97,5 +97,6 @@ class EmaDocument(AbstractDocument):
related_name="documents",
)
file = models.FileField(
upload_to=generate_document_file_upload_path
upload_to=generate_document_file_upload_path,
max_length=1000,
)
+5 -3
View File
@@ -86,7 +86,8 @@ class RevocationDocument(AbstractDocument):
related_name="document",
)
file = models.FileField(
upload_to=generate_document_file_upload_path
upload_to=generate_document_file_upload_path,
max_length=1000,
)
@property
@@ -334,5 +335,6 @@ class InterventionDocument(AbstractDocument):
related_name="documents",
)
file = models.FileField(
upload_to=generate_document_file_upload_path
)
upload_to=generate_document_file_upload_path,
max_length=1000,
)
+5 -2
View File
@@ -5,7 +5,7 @@ Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 01.09.21
"""
from django.http import FileResponse, HttpRequest
from django.http import FileResponse, HttpRequest, HttpResponse, Http404
from django.utils.translation import gettext_lazy as _
from konova.forms import RemoveModalForm
@@ -22,7 +22,10 @@ def get_document(doc: AbstractDocument):
Returns:
"""
return FileResponse(doc.file, as_attachment=True)
try:
return FileResponse(doc.file, as_attachment=True)
except FileNotFoundError:
raise Http404()
def remove_document(request: HttpRequest, doc: AbstractDocument):