# Document views refactoring

* refactors new, edit, get and delete views for eiv, kom, oek and ema
* introduces
This commit is contained in:
2025-10-21 13:48:16 +02:00
parent e0b8922494
commit efb76278b4
13 changed files with 219 additions and 312 deletions

View File

@@ -6,11 +6,11 @@ Created on: 18.08.22
"""
from intervention.models import InterventionDocument
from konova.forms.modals import NewDocumentModalForm
from konova.forms.modals import NewDocumentModalForm, EditDocumentModalForm, RemoveDocumentModalForm
class NewInterventionDocumentModalForm(NewDocumentModalForm):
document_model = InterventionDocument
_DOCUMENT_CLS = InterventionDocument
def save(self, *args, **kwargs):
""" Extension of regular NewDocumentModalForm
@@ -28,3 +28,31 @@ class NewInterventionDocumentModalForm(NewDocumentModalForm):
self.instance.send_data_to_egon()
return doc
class EditInterventionDocumentModalForm(EditDocumentModalForm):
_DOCUMENT_CLS = InterventionDocument
def save(self, *args, **kwargs):
""" Extension of regular EditDocumentModalForm
Checks whether payments exist on the intervention and sends the data to EGON
Args:
*args ():
**kwargs ():
Returns:
"""
doc = super().save(*args, **kwargs)
self.instance.send_data_to_egon()
return doc
class RemoveInterventionDocumentModalForm(RemoveDocumentModalForm):
_DOCUMENT_CLS = InterventionDocument
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
self.instance.send_data_to_egon()

View File

@@ -5,59 +5,33 @@ Contact: ksp-servicestelle@sgdnord.rlp.de
Created on: 19.08.22
"""
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from intervention.forms.modals.document import NewInterventionDocumentModalForm
from intervention.forms.modals.document import NewInterventionDocumentModalForm, EditInterventionDocumentModalForm, \
RemoveInterventionDocumentModalForm
from intervention.models import Intervention, InterventionDocument
from konova.decorators import default_group_required, shared_access_required
from konova.forms.modals import EditDocumentModalForm
from konova.views.document import AbstractNewDocumentView, AbstractGetDocumentView, AbstractRemoveDocumentView, \
AbstractEditDocumentView
class NewInterventionDocumentView(AbstractNewDocumentView):
model = Intervention
form = NewInterventionDocumentModalForm
redirect_url = "intervention:detail"
@method_decorator(login_required)
@method_decorator(default_group_required)
@method_decorator(shared_access_required(Intervention, "id"))
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
_MODEL_CLS = Intervention
_DOCUMENT_MODEL = InterventionDocument
_FORM_CLS = NewInterventionDocumentModalForm
_REDIRECT_URL = "intervention:detail"
class GetInterventionDocumentView(AbstractGetDocumentView):
model = Intervention
document_model = InterventionDocument
@method_decorator(login_required)
@method_decorator(default_group_required)
@method_decorator(shared_access_required(Intervention, "id"))
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
_MODEL_CLS = Intervention
_DOCUMENT_CLS = InterventionDocument
class RemoveInterventionDocumentView(AbstractRemoveDocumentView):
model = Intervention
document_model = InterventionDocument
@method_decorator(login_required)
@method_decorator(default_group_required)
@method_decorator(shared_access_required(Intervention, "id"))
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
_MODEL_CLS = Intervention
_DOCUMENT_CLS = InterventionDocument
_FORM_CLS = RemoveInterventionDocumentModalForm
_REDIRECT_URL = "intervention:detail"
class EditInterventionDocumentView(AbstractEditDocumentView):
model = Intervention
document_model = InterventionDocument
form = EditDocumentModalForm
redirect_url = "intervention:detail"
@method_decorator(login_required)
@method_decorator(default_group_required)
@method_decorator(shared_access_required(Intervention, "id"))
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
_MODEL_CLS = Intervention
_DOCUMENT_CLS = InterventionDocument
_FORM_CLS = EditInterventionDocumentModalForm
_REDIRECT_URL = "intervention:detail"