#86 Edit document
* adds support for editing of documents * adds buttons for intervention
This commit is contained in:
@@ -19,7 +19,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from compensation.models import EcoAccount, EcoAccountDeduction
|
||||
from intervention.inputs import TextToClipboardInput
|
||||
from intervention.models import Intervention, InterventionDocument, RevocationDocument
|
||||
from konova.forms import BaseModalForm, NewDocumentForm, RemoveModalForm
|
||||
from konova.forms import BaseModalForm, NewDocumentModalForm, RemoveModalForm
|
||||
from konova.utils.general import format_german_float
|
||||
from konova.utils.user_checks import is_default_group_only
|
||||
|
||||
@@ -170,32 +170,6 @@ class NewRevocationModalForm(BaseModalForm):
|
||||
"enctype": "multipart/form-data", # important for file upload
|
||||
}
|
||||
|
||||
def is_valid(self):
|
||||
super_valid = super().is_valid()
|
||||
|
||||
_file = self.cleaned_data.get("file", None)
|
||||
|
||||
if isinstance(_file, FieldFile):
|
||||
# FieldFile declares that no new file has been uploaded and we do not need to check on the file again
|
||||
return super_valid
|
||||
|
||||
mime_type_valid = self.document_model.is_mime_type_valid(_file)
|
||||
if not mime_type_valid:
|
||||
self.add_error(
|
||||
"file",
|
||||
FILE_TYPE_UNSUPPORTED
|
||||
)
|
||||
|
||||
file_size_valid = self.document_model.is_file_size_valid(_file)
|
||||
if not file_size_valid:
|
||||
self.add_error(
|
||||
"file",
|
||||
FILE_SIZE_TOO_LARGE
|
||||
)
|
||||
|
||||
file_valid = mime_type_valid and file_size_valid
|
||||
return super_valid and file_valid
|
||||
|
||||
def save(self):
|
||||
revocation = self.instance.add_revocation(self)
|
||||
self.instance.mark_as_edited(self.user, self.request, edit_comment=REVOCATION_ADDED)
|
||||
@@ -543,5 +517,5 @@ class RemoveEcoAccountDeductionModalForm(RemoveModalForm):
|
||||
self.deduction.delete()
|
||||
|
||||
|
||||
class NewInterventionDocumentForm(NewDocumentForm):
|
||||
class NewInterventionDocumentModalForm(NewDocumentModalForm):
|
||||
document_model = InterventionDocument
|
||||
|
||||
Reference in New Issue
Block a user