From a147626174485a49791a96152fdffebda6ef6c4d Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Mon, 7 Feb 2022 09:56:37 +0100 Subject: [PATCH] # 86 Deadline removal log entry * adds log entries if deadline is removed --- compensation/forms/modalForms.py | 1 - compensation/models/compensation.py | 18 +++++++++++++++++- compensation/views/compensation.py | 12 +++++++----- compensation/views/eco_account.py | 11 ++++++----- ema/views.py | 11 ++++++----- konova/forms.py | 17 +++++++++++++++++ konova/utils/message_templates.py | 4 ++++ locale/de/LC_MESSAGES/django.mo | Bin 36530 -> 36537 bytes locale/de/LC_MESSAGES/django.po | 2 +- 9 files changed, 58 insertions(+), 18 deletions(-) diff --git a/compensation/forms/modalForms.py b/compensation/forms/modalForms.py index 9331f60a..c1761736 100644 --- a/compensation/forms/modalForms.py +++ b/compensation/forms/modalForms.py @@ -271,7 +271,6 @@ class NewDeadlineModalForm(BaseModalForm): def save(self): deadline = self.instance.add_deadline(self) - self.instance.mark_as_edited(self.user, self.request, ADDED_DEADLINE) return deadline diff --git a/compensation/models/compensation.py b/compensation/models/compensation.py index ef8e20fe..e2dc9c89 100644 --- a/compensation/models/compensation.py +++ b/compensation/models/compensation.py @@ -21,7 +21,7 @@ from konova.models import BaseObject, AbstractDocument, Deadline, generate_docum GeoReferencedMixin from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, COMPENSATION_REMOVED_TEMPLATE, \ - DOCUMENT_REMOVED_TEMPLATE, COMPENSATION_EDITED_TEMPLATE + DOCUMENT_REMOVED_TEMPLATE, COMPENSATION_EDITED_TEMPLATE, DEADLINE_REMOVED, ADDED_DEADLINE from user.models import UserActionLogEntry @@ -71,8 +71,24 @@ class AbstractCompensation(BaseObject, GeoReferencedMixin): self.save() self.deadlines.add(deadline) + self.mark_as_edited(user, edit_comment=ADDED_DEADLINE) return deadline + def remove_deadline(self, form): + """ Removes a deadline from the abstract compensation + + Args: + form (DeadlineRemoveModalForm): The form holding all relevant data + + Returns: + + """ + deadline = form.deadline + user = form.user + with transaction.atomic(): + deadline.delete() + self.mark_as_edited(user, edit_comment=DEADLINE_REMOVED) + def add_action(self, form) -> CompensationAction: """ Adds a new action to the compensation diff --git a/compensation/views/compensation.py b/compensation/views/compensation.py index 26e53fd2..e2456ecd 100644 --- a/compensation/views/compensation.py +++ b/compensation/views/compensation.py @@ -12,14 +12,15 @@ from compensation.tables import CompensationTable from intervention.models import Intervention from konova.contexts import BaseContext from konova.decorators import * -from konova.forms import RemoveModalForm, SimpleGeomForm +from konova.forms import RemoveModalForm, SimpleGeomForm, DeadlineRemoveModalForm from konova.models import Deadline from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER from konova.utils.documents import get_document, remove_document from konova.utils.generators import generate_qr_code from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED, DATA_UNSHARED_EXPLANATION, \ CHECKED_RECORDED_RESET, COMPENSATION_ADDED_TEMPLATE, COMPENSATION_REMOVED_TEMPLATE, DOCUMENT_ADDED, \ - COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED + COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, \ + DEADLINE_ADDED, DEADLINE_REMOVED from konova.utils.user_checks import in_group @@ -392,7 +393,7 @@ def deadline_new_view(request: HttpRequest, id: str): form = NewDeadlineModalForm(request.POST or None, instance=comp, request=request) return form.process_request( request, - msg_success=_("Deadline added"), + msg_success=DEADLINE_ADDED, redirect_url=reverse("compensation:detail", args=(id,)) + "#related_data" ) @@ -411,11 +412,12 @@ def deadline_remove_view(request: HttpRequest, id: str, deadline_id: str): Returns: """ + comp = get_object_or_404(Compensation, id=id) deadline = get_object_or_404(Deadline, id=deadline_id) - form = RemoveModalForm(request.POST or None, instance=deadline, request=request) + form = DeadlineRemoveModalForm(request.POST or None, instance=comp, deadline=deadline, request=request) return form.process_request( request, - msg_success=_("Deadline removed"), + msg_success=DEADLINE_REMOVED, redirect_url=reverse("compensation:detail", args=(id,)) + "#related_data" ) diff --git a/compensation/views/eco_account.py b/compensation/views/eco_account.py index 27a113cb..34f979f0 100644 --- a/compensation/views/eco_account.py +++ b/compensation/views/eco_account.py @@ -23,7 +23,7 @@ from intervention.forms.modalForms import NewDeductionModalForm, ShareModalForm from konova.contexts import BaseContext from konova.decorators import any_group_check, default_group_required, conservation_office_group_required, \ shared_access_required -from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordModalForm +from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordModalForm, DeadlineRemoveModalForm from konova.models import Deadline from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER @@ -31,7 +31,7 @@ from konova.utils.documents import get_document, remove_document from konova.utils.generators import generate_qr_code from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \ CANCEL_ACC_RECORDED_OR_DEDUCTED, DEDUCTION_REMOVED, DEDUCTION_ADDED, DOCUMENT_ADDED, COMPENSATION_STATE_REMOVED, \ - COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED + COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, DEADLINE_ADDED, DEADLINE_REMOVED from konova.utils.user_checks import in_group @@ -447,11 +447,12 @@ def deadline_remove_view(request: HttpRequest, id: str, deadline_id: str): Returns: """ + comp = get_object_or_404(EcoAccount, id=id) deadline = get_object_or_404(Deadline, id=deadline_id) - form = RemoveModalForm(request.POST or None, instance=deadline, request=request) + form = DeadlineRemoveModalForm(request.POST or None, instance=comp, deadline=deadline, request=request) return form.process_request( request, - msg_success=_("Deadline removed"), + msg_success=DEADLINE_REMOVED, redirect_url=reverse("compensation:acc:detail", args=(id,)) + "#related_data" ) @@ -473,7 +474,7 @@ def deadline_new_view(request: HttpRequest, id: str): form = NewDeadlineModalForm(request.POST or None, instance=acc, request=request) return form.process_request( request, - msg_success=_("Deadline added"), + msg_success=DEADLINE_ADDED, redirect_url=reverse("compensation:acc:detail", args=(id,)) + "#related_data" ) diff --git a/ema/views.py b/ema/views.py index 44a92c93..82bfcdc0 100644 --- a/ema/views.py +++ b/ema/views.py @@ -14,7 +14,7 @@ from intervention.forms.modalForms import ShareModalForm from konova.contexts import BaseContext from konova.decorators import conservation_office_group_required, shared_access_required from ema.models import Ema, EmaDocument -from konova.forms import RemoveModalForm, SimpleGeomForm, RecordModalForm +from konova.forms import RemoveModalForm, SimpleGeomForm, RecordModalForm, DeadlineRemoveModalForm from konova.models import Deadline from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER @@ -22,7 +22,7 @@ from konova.utils.documents import get_document, remove_document from konova.utils.generators import generate_qr_code from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \ DOCUMENT_ADDED, COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, \ - COMPENSATION_ACTION_ADDED + COMPENSATION_ACTION_ADDED, DEADLINE_ADDED, DEADLINE_REMOVED from konova.utils.user_checks import in_group @@ -337,7 +337,7 @@ def deadline_new_view(request: HttpRequest, id: str): form = NewDeadlineModalForm(request.POST or None, instance=ema, request=request) return form.process_request( request, - msg_success=_("Deadline added"), + msg_success=DEADLINE_ADDED, redirect_url=reverse("ema:detail", args=(id,)) + "#related_data" ) @@ -590,10 +590,11 @@ def deadline_remove_view(request: HttpRequest, id: str, deadline_id: str): Returns: """ + ema = get_object_or_404(Ema, id=id) deadline = get_object_or_404(Deadline, id=deadline_id) - form = RemoveModalForm(request.POST or None, instance=deadline, request=request) + form = DeadlineRemoveModalForm(request.POST or None, instance=ema, deadline=deadline, request=request) return form.process_request( request, - msg_success=_("Deadline removed"), + msg_success=DEADLINE_REMOVED, redirect_url=reverse("ema:detail", args=(id,)) + "#related_data" ) \ No newline at end of file diff --git a/konova/forms.py b/konova/forms.py index ab55cb75..8b7539b3 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -330,6 +330,23 @@ class RemoveModalForm(BaseModalForm): self.instance.delete(self.user) +class DeadlineRemoveModalForm(RemoveModalForm): + """ Removing modal form for deadlines + + Can be used for anything, where removing shall be confirmed by the user a second time. + + """ + deadline = None + + def __init__(self, *args, **kwargs): + deadline = kwargs.pop("deadline", None) + self.deadline = deadline + super().__init__(*args, **kwargs) + + def save(self): + self.instance.remove_deadline(self) + + class NewDocumentForm(BaseModalForm): """ Modal form for new documents diff --git a/konova/utils/message_templates.py b/konova/utils/message_templates.py index c38b2e86..e13a9cae 100644 --- a/konova/utils/message_templates.py +++ b/konova/utils/message_templates.py @@ -40,6 +40,10 @@ COMPENSATION_ACTION_REMOVED = _("Action removed") DEDUCTION_ADDED = _("Deduction added") DEDUCTION_REMOVED = _("Deduction removed") +# DEADLINE +DEADLINE_ADDED = _("Deadline added") +DEADLINE_REMOVED = _("Deadline removed") + # PAYMENTS PAYMENT_ADDED = _("Payment added") PAYMENT_REMOVED = _("Payment removed") diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index 23892cf84d1776aa8f508d127e5ea2d93a2b6cac..c25c2f113b0cf7f234e21d82feaf2dcc8f869568 100644 GIT binary patch delta 3137 zcmXZedra3=7{~D=D*ogq-athKZwPV|$}*8qDs|p6BsZFiIR}UeqCy5rUjrmH)LC=k z1#OW_agnCrr3up1*-W?6a)mk9#mbzy(v_yJ_lI--(ARmsmvf%;oO8ZEKCSmVUhj8s zS069T7?YN3Okd1GA1=ZyT<$!Jb;J>Q#_0JY*ay#JAYQ{zyorPGKU6YvPeqe!3 zI1C38C!ofgin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^dRnf)` zT7MenxS&#AL=E&kM&V7=j6&I&iephrG6nTqp0fefjTw?{6ZDrUQEECYHKq3iJ!$JEJr19$lX7Nvxqx! zE)L(!?*kTkG*;1QLS^LNVt4IG)Fw(sbuh-mga=9zi|dgdy0B z>gNoqLZ7bVvi%lM{^hJIvz!ErcroBdlb0~J@H5;}=Go~@XPf1*AlbKkV5WCi+(D{wg0 u;z&I0{1JN-2XD7uz;LNwwMjIznR2loZb3b`*Tr>Bhhz4oH_cg5l=wf&skEB_ diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 65808d43..eb1b60a4 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -1117,7 +1117,7 @@ msgstr "Frist/Termin hinzugefügt" #: compensation/views/compensation.py:417 compensation/views/eco_account.py:453 #: ema/views.py:595 msgid "Deadline removed" -msgstr "Frist gelöscht" +msgstr "Frist/Termin gelöscht" #: compensation/views/compensation.py:440 compensation/views/eco_account.py:407 #: ema/views.py:430