#18 File upload in certain folders
* refactors documents and file upload to be distributed into different subfolders, depending on the type of document (InterventionDocument, RevocationDocument, ...) * refactors Document model into AbstractDocument * subclasses RevocationDocument, InterventionDocument, COmpensationDocument, EmaDocument and EcoAccountDocument from AbstractDocument to provide proper functionality for each * adds new specialized routes for each new document type (opening, removing) * drops generic get and remove routes for documents
This commit is contained in:
+39
-1
@@ -10,9 +10,10 @@ from compensation.forms import NewStateModalForm, NewActionModalForm, NewDeadlin
|
||||
from ema.tables import EmaTable
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import conservation_office_group_required
|
||||
from ema.models import Ema
|
||||
from ema.models import Ema, EmaDocument
|
||||
from konova.forms import RemoveModalForm, NewDocumentForm, SimpleGeomForm, RecordModalForm
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
from konova.utils.documents import get_document, remove_document
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
|
||||
@@ -250,6 +251,43 @@ def document_new_view(request: HttpRequest, id: str):
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def get_document_view(request: HttpRequest, doc_id: str):
|
||||
""" Returns the document as downloadable file
|
||||
|
||||
Wraps the generic document fetcher function from konova.utils.
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
doc_id (str): The document id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
doc = get_object_or_404(EmaDocument, id=doc_id)
|
||||
return get_document(doc)
|
||||
|
||||
|
||||
@login_required
|
||||
def remove_document_view(request: HttpRequest, doc_id: str):
|
||||
""" Removes the document from the database and file system
|
||||
|
||||
Wraps the generic functionality from konova.utils.
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
doc_id (str): The document id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
doc = get_object_or_404(EmaDocument, id=doc_id)
|
||||
return remove_document(
|
||||
request,
|
||||
doc
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def state_remove_view(request: HttpRequest, id: str):
|
||||
""" Renders a form for removing an EMA state
|
||||
|
||||
Reference in New Issue
Block a user