# EditIntervention view
* refactors edit intervention view from function to class
This commit is contained in:
@@ -23,7 +23,8 @@ from konova.forms.modals import RemoveModalForm
|
||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||
from konova.utils.message_templates import DATA_CHECKED_PREVIOUSLY_TEMPLATE, RECORDED_BLOCKS_EDIT, \
|
||||
CHECK_STATE_RESET, FORM_INVALID, GEOMETRY_SIMPLIFIED, GEOMETRIES_IGNORED_TEMPLATE
|
||||
from konova.views.base import BaseIndexView, BaseIdentifierGeneratorView, BaseNewSpatialLocatedObjectFormView
|
||||
from konova.views.base import BaseIndexView, BaseIdentifierGeneratorView, BaseNewSpatialLocatedObjectFormView, \
|
||||
BaseEditSpatialLocatedObjectFormView
|
||||
from konova.views.detail import BaseDetailView
|
||||
|
||||
|
||||
@@ -50,6 +51,21 @@ class NewInterventionFormView(BaseNewSpatialLocatedObjectFormView):
|
||||
_TAB_TITLE = _("New intervention")
|
||||
|
||||
|
||||
class EditInterventionFormView(BaseEditSpatialLocatedObjectFormView):
|
||||
_MODEL_CLS = Intervention
|
||||
_FORM_CLS = EditInterventionForm
|
||||
_TEMPLATE = "intervention/form/view.html"
|
||||
_REDIRECT_URL = "intervention:detail"
|
||||
_TAB_TITLE = _("Edit {}")
|
||||
|
||||
def _user_has_shared_access(self, user, **kwargs):
|
||||
obj = get_object_or_404(self._REDIRECT_URL, id=kwargs.get('id', None))
|
||||
return obj.is_shared_with(user)
|
||||
|
||||
def _user_has_permission(self, user):
|
||||
return user.is_default_user()
|
||||
|
||||
|
||||
class InterventionIdentifierGeneratorView(LoginRequiredMixin, BaseIdentifierGeneratorView):
|
||||
_MODEL_CLS = Intervention
|
||||
_REDIRECT_URL = "intervention:index"
|
||||
|
||||
Reference in New Issue
Block a user