#36 Quality checks
* adds unchecking/unrecording of interventions in case of post-check|post-record editing
This commit is contained in:
@@ -355,5 +355,9 @@ class EditInterventionForm(NewInterventionForm):
|
||||
self.instance.modified = user_action
|
||||
self.instance.save()
|
||||
|
||||
# Uncheck and unrecord intervention due to changed data
|
||||
self.instance.set_unchecked(user)
|
||||
self.instance.set_unrecorded(user)
|
||||
|
||||
return self.instance
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ from codelist.settings import CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVA
|
||||
from intervention.managers import InterventionManager
|
||||
from intervention.utils.quality import InterventionQualityChecker
|
||||
from konova.models import BaseObject, Geometry, UuidModel, BaseResource, AbstractDocument, \
|
||||
generate_document_file_upload_path, RecordableMixin
|
||||
generate_document_file_upload_path, RecordableMixin, CheckableMixin
|
||||
from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE, LANIS_ZOOM_LUT
|
||||
from konova.utils import generators
|
||||
from user.models import UserActionLogEntry
|
||||
@@ -171,7 +171,7 @@ class LegalData(UuidModel):
|
||||
revocation = models.OneToOneField(Revocation, null=True, blank=True, help_text="Refers to 'Widerspruch am'", on_delete=models.SET_NULL)
|
||||
|
||||
|
||||
class Intervention(BaseObject, RecordableMixin):
|
||||
class Intervention(BaseObject, RecordableMixin, CheckableMixin):
|
||||
"""
|
||||
Interventions are e.g. construction sites where nature used to be.
|
||||
"""
|
||||
@@ -273,11 +273,11 @@ class Intervention(BaseObject, RecordableMixin):
|
||||
|
||||
"""
|
||||
if self.identifier is None or len(self.identifier) == 0:
|
||||
# No identifier given
|
||||
# No identifier given by the user
|
||||
self.identifier = self.generate_new_identifier()
|
||||
|
||||
# Before saving, make sure the set identifier is not used, yet
|
||||
while Intervention.objects.filter(identifier=self.identifier).exists():
|
||||
# Before saving, make sure the given identifier is not used in the meanwhile
|
||||
while Intervention.objects.filter(identifier=self.identifier).exclude(id=self.id).exists():
|
||||
self.identifier = self.generate_new_identifier()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT
|
||||
from konova.utils.documents import remove_document, get_document
|
||||
from konova.utils.generators import generate_qr_code
|
||||
from konova.utils.message_templates import INTERVENTION_INVALID, FORM_INVALID, IDENTIFIER_REPLACED, \
|
||||
DATA_UNSHARED_EXPLANATION
|
||||
DATA_UNSHARED_EXPLANATION, CHECKED_RECORDED_RESET
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
|
||||
@@ -270,8 +270,13 @@ def edit_view(request: HttpRequest, id: str):
|
||||
if request.method == "POST":
|
||||
if data_form.is_valid() and geom_form.is_valid():
|
||||
# The data form takes the geom form for processing, as well as the performing user
|
||||
# Save the current state of recorded|checked to inform the user in case of a status reset due to editing
|
||||
i_rec = intervention.recorded is not None
|
||||
i_check = intervention.checked is not None
|
||||
intervention = data_form.save(request.user, geom_form)
|
||||
messages.success(request, _("Intervention {} edited").format(intervention.identifier))
|
||||
if i_check or i_rec:
|
||||
messages.info(request, CHECKED_RECORDED_RESET)
|
||||
return redirect("intervention:detail", id=intervention.id)
|
||||
else:
|
||||
messages.error(request, FORM_INVALID, extra_tags="danger",)
|
||||
|
||||
Reference in New Issue
Block a user