From 6cdf355063f68005aacf97a2595e9c244655b8ea Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Tue, 8 Feb 2022 13:16:20 +0100 Subject: [PATCH] #86 Log detail enhancements * restructures removing of related data into separate sub-delete forms for easier logic handling --- compensation/forms/modalForms.py | 54 +++++++++++++++++- compensation/models/action.py | 10 ---- compensation/models/compensation.py | 35 +++++++++++- compensation/models/payment.py | 5 -- compensation/models/state.py | 11 ---- compensation/urls/payment.py | 4 +- compensation/views/compensation.py | 8 ++- compensation/views/eco_account.py | 12 ++-- compensation/views/payment.py | 20 ++++--- ema/views.py | 9 ++- intervention/forms/modalForms.py | 41 ++++++++++++- intervention/models/intervention.py | 37 +++++++++++- intervention/models/revocation.py | 5 +- .../detail/includes/payments.html | 2 +- .../detail/includes/revocation.html | 2 +- intervention/tests/test_workflow.py | 2 +- intervention/urls.py | 6 +- intervention/views.py | 14 +++-- konova/forms.py | 2 +- locale/de/LC_MESSAGES/django.mo | Bin 36537 -> 36538 bytes locale/de/LC_MESSAGES/django.po | 2 +- 21 files changed, 206 insertions(+), 75 deletions(-) diff --git a/compensation/forms/modalForms.py b/compensation/forms/modalForms.py index c1761736..a31dda0c 100644 --- a/compensation/forms/modalForms.py +++ b/compensation/forms/modalForms.py @@ -18,7 +18,7 @@ from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_COMPENSATION_ACTION CODELIST_COMPENSATION_ACTION_DETAIL_ID from compensation.models import CompensationDocument, EcoAccountDocument from konova.contexts import BaseContext -from konova.forms import BaseModalForm, NewDocumentForm +from konova.forms import BaseModalForm, NewDocumentForm, RemoveModalForm from konova.models import DeadlineType from konova.utils.message_templates import FORM_INVALID, ADDED_COMPENSATION_STATE, ADDED_DEADLINE, \ ADDED_COMPENSATION_ACTION, PAYMENT_ADDED @@ -100,10 +100,26 @@ class NewPaymentForm(BaseModalForm): def save(self): pay = self.instance.add_payment(self) - self.instance.mark_as_edited(self.user, self.request, edit_comment=PAYMENT_ADDED) return pay +class PaymentRemoveModalForm(RemoveModalForm): + """ Removing modal form for Payment + + Can be used for anything, where removing shall be confirmed by the user a second time. + + """ + payment = None + + def __init__(self, *args, **kwargs): + payment = kwargs.pop("payment", None) + self.payment = payment + super().__init__(*args, **kwargs) + + def save(self): + self.instance.remove_payment(self) + + class NewStateModalForm(BaseModalForm): """ Form handling state related input @@ -219,6 +235,40 @@ class NewStateModalForm(BaseModalForm): raise NotImplementedError +class CompensationStateRemoveModalForm(RemoveModalForm): + """ Removing modal form for CompensationState + + Can be used for anything, where removing shall be confirmed by the user a second time. + + """ + state = None + + def __init__(self, *args, **kwargs): + state = kwargs.pop("state", None) + self.state = state + super().__init__(*args, **kwargs) + + def save(self): + self.instance.remove_state(self) + + +class CompensationActionRemoveModalForm(RemoveModalForm): + """ Removing modal form for CompensationAction + + Can be used for anything, where removing shall be confirmed by the user a second time. + + """ + action = None + + def __init__(self, *args, **kwargs): + action = kwargs.pop("action", None) + self.action = action + super().__init__(*args, **kwargs) + + def save(self): + self.instance.remove_action(self) + + class NewDeadlineModalForm(BaseModalForm): """ Form handling deadline related input diff --git a/compensation/models/action.py b/compensation/models/action.py index bd2400e7..a5579159 100644 --- a/compensation/models/action.py +++ b/compensation/models/action.py @@ -76,13 +76,3 @@ class CompensationAction(BaseResource): if choice[0] == self.unit: return choice[1] return None - - def delete(self, user=None, *args, **kwargs): - from compensation.models import Compensation - if user: - comps = Compensation.objects.filter( - actions__id__in=[self.id] - ).distinct() - for comp in comps: - comp.mark_as_edited(user, edit_comment=COMPENSATION_ACTION_REMOVED) - super().delete(*args, **kwargs) \ No newline at end of file diff --git a/compensation/models/compensation.py b/compensation/models/compensation.py index e2dc9c89..46476a67 100644 --- a/compensation/models/compensation.py +++ b/compensation/models/compensation.py @@ -21,7 +21,8 @@ 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, DEADLINE_REMOVED, ADDED_DEADLINE + DOCUMENT_REMOVED_TEMPLATE, COMPENSATION_EDITED_TEMPLATE, DEADLINE_REMOVED, ADDED_DEADLINE, \ + COMPENSATION_ACTION_REMOVED, COMPENSATION_STATE_REMOVED from user.models import UserActionLogEntry @@ -114,6 +115,21 @@ class AbstractCompensation(BaseObject, GeoReferencedMixin): self.actions.add(comp_action) return comp_action + def remove_action(self, form): + """ Removes a CompensationAction from the abstract compensation + + Args: + form (CompensationActionRemoveModalForm): The form holding all relevant data + + Returns: + + """ + action = form.action + user = form.user + with transaction.atomic(): + action.delete() + self.mark_as_edited(user, edit_comment=COMPENSATION_ACTION_REMOVED) + def add_state(self, form, is_before_state: bool) -> CompensationState: """ Adds a new compensation state to the compensation @@ -138,6 +154,21 @@ class AbstractCompensation(BaseObject, GeoReferencedMixin): self.after_states.add(state) return state + def remove_state(self, form): + """ Removes a CompensationState from the abstract compensation + + Args: + form (CompensationStateRemoveModalForm): The form holding all relevant data + + Returns: + + """ + state = form.state + user = form.user + with transaction.atomic(): + state.delete() + self.mark_as_edited(user, edit_comment=COMPENSATION_STATE_REMOVED) + def get_surface_after_states(self) -> float: """ Calculates the compensation's/account's surface @@ -346,7 +377,7 @@ class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin): """ self.intervention.unrecord(user, request) - action = super().mark_as_edited(user, edit_comment) + action = super().mark_as_edited(user, edit_comment=edit_comment) return action def is_ready_for_publish(self) -> bool: diff --git a/compensation/models/payment.py b/compensation/models/payment.py index 48eec3fc..6f3f4c24 100644 --- a/compensation/models/payment.py +++ b/compensation/models/payment.py @@ -37,8 +37,3 @@ class Payment(BaseResource): ordering = [ "-amount", ] - - def delete(self, user=None, *args, **kwargs): - if user is not None: - self.intervention.mark_as_edited(user, edit_comment=PAYMENT_REMOVED) - super().delete(*args, **kwargs) diff --git a/compensation/models/state.py b/compensation/models/state.py index 02249145..5cb8376a 100644 --- a/compensation/models/state.py +++ b/compensation/models/state.py @@ -47,14 +47,3 @@ class CompensationState(UuidModel): def __str__(self): return f"{self.biotope_type} | {self.surface} m²" - - def delete(self, user=None, *args, **kwargs): - from compensation.models import Compensation - if user: - comps = Compensation.objects.filter( - Q(before_states__id__in=[self.id]) | - Q(after_states__id__in=[self.id]) - ).distinct() - for comp in comps: - comp.mark_as_edited(user, edit_comment=COMPENSATION_STATE_REMOVED) - super().delete(*args, **kwargs) diff --git a/compensation/urls/payment.py b/compensation/urls/payment.py index 2c8e5d4b..a400c636 100644 --- a/compensation/urls/payment.py +++ b/compensation/urls/payment.py @@ -10,6 +10,6 @@ from compensation.views.payment import * app_name = "pay" urlpatterns = [ - path('/new', new_payment_view, name='new'), - path('/remove', payment_remove_view, name='remove'), + path('/new', new_payment_view, name='new'), + path('/remove/', payment_remove_view, name='remove'), ] diff --git a/compensation/views/compensation.py b/compensation/views/compensation.py index e2456ecd..eb4dd371 100644 --- a/compensation/views/compensation.py +++ b/compensation/views/compensation.py @@ -6,7 +6,7 @@ from django.utils.translation import gettext_lazy as _ from compensation.forms.forms import NewCompensationForm, EditCompensationForm from compensation.forms.modalForms import NewStateModalForm, NewDeadlineModalForm, NewActionModalForm, \ - NewCompensationDocumentForm + NewCompensationDocumentForm, CompensationActionRemoveModalForm, CompensationStateRemoveModalForm from compensation.models import Compensation, CompensationState, CompensationAction, CompensationDocument from compensation.tables import CompensationTable from intervention.models import Intervention @@ -436,8 +436,9 @@ def state_remove_view(request: HttpRequest, id: str, state_id: str): Returns: """ + comp = get_object_or_404(Compensation, id=id) state = get_object_or_404(CompensationState, id=state_id) - form = RemoveModalForm(request.POST or None, instance=state, request=request) + form = CompensationStateRemoveModalForm(request.POST or None, instance=comp, state=state, request=request) return form.process_request( request, msg_success=COMPENSATION_STATE_REMOVED, @@ -459,8 +460,9 @@ def action_remove_view(request: HttpRequest, id: str, action_id: str): Returns: """ + comp = get_object_or_404(Compensation, id=id) action = get_object_or_404(CompensationAction, id=action_id) - form = RemoveModalForm(request.POST or None, instance=action, request=request) + form = CompensationActionRemoveModalForm(request.POST or None, instance=comp, action=action, request=request) return form.process_request( request, msg_success=COMPENSATION_ACTION_REMOVED, diff --git a/compensation/views/eco_account.py b/compensation/views/eco_account.py index 34f979f0..f6cced09 100644 --- a/compensation/views/eco_account.py +++ b/compensation/views/eco_account.py @@ -16,10 +16,10 @@ from django.shortcuts import render, get_object_or_404, redirect from compensation.forms.forms import NewEcoAccountForm, EditEcoAccountForm from compensation.forms.modalForms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm, \ - NewEcoAccountDocumentForm + NewEcoAccountDocumentForm, CompensationActionRemoveModalForm, CompensationStateRemoveModalForm from compensation.models import EcoAccount, EcoAccountDocument, CompensationState, CompensationAction from compensation.tables import EcoAccountTable -from intervention.forms.modalForms import NewDeductionModalForm, ShareModalForm +from intervention.forms.modalForms import NewDeductionModalForm, ShareModalForm, DeductionRemoveModalForm from konova.contexts import BaseContext from konova.decorators import any_group_check, default_group_required, conservation_office_group_required, \ shared_access_required @@ -286,7 +286,7 @@ def deduction_remove_view(request: HttpRequest, id: str, deduction_id: str): except ObjectDoesNotExist: raise Http404("Unknown deduction") - form = RemoveModalForm(request.POST or None, instance=eco_deduction, request=request) + form = DeductionRemoveModalForm(request.POST or None, instance=acc, deduction=eco_deduction, request=request) return form.process_request( request=request, msg_success=DEDUCTION_REMOVED, @@ -401,8 +401,9 @@ def state_remove_view(request: HttpRequest, id: str, state_id: str): Returns: """ + acc = get_object_or_404(EcoAccount, id=id) state = get_object_or_404(CompensationState, id=state_id) - form = RemoveModalForm(request.POST or None, instance=state, request=request) + form = CompensationStateRemoveModalForm(request.POST or None, instance=acc, state=state, request=request) return form.process_request( request, msg_success=COMPENSATION_STATE_REMOVED, @@ -424,8 +425,9 @@ def action_remove_view(request: HttpRequest, id: str, action_id: str): Returns: """ + acc = get_object_or_404(EcoAccount, id=id) action = get_object_or_404(CompensationAction, id=action_id) - form = RemoveModalForm(request.POST or None, instance=action, request=request) + form = CompensationActionRemoveModalForm(request.POST or None, instance=acc, action=action, request=request) return form.process_request( request, msg_success=COMPENSATION_ACTION_REMOVED, diff --git a/compensation/views/payment.py b/compensation/views/payment.py index b715a3ae..d1fa91b2 100644 --- a/compensation/views/payment.py +++ b/compensation/views/payment.py @@ -11,7 +11,7 @@ from django.contrib.auth.decorators import login_required from django.http import HttpRequest from django.shortcuts import get_object_or_404 -from compensation.forms.modalForms import NewPaymentForm +from compensation.forms.modalForms import NewPaymentForm, PaymentRemoveModalForm from compensation.models import Payment from intervention.models import Intervention from konova.decorators import default_group_required @@ -21,39 +21,41 @@ from konova.utils.message_templates import PAYMENT_ADDED, PAYMENT_REMOVED @login_required @default_group_required -def new_payment_view(request: HttpRequest, intervention_id: str): +def new_payment_view(request: HttpRequest, id: str): """ Renders a modal view for adding new payments Args: request (HttpRequest): The incoming request - intervention_id (str): The intervention's id for which a new payment shall be added + id (str): The intervention's id for which a new payment shall be added Returns: """ - intervention = get_object_or_404(Intervention, id=intervention_id) + intervention = get_object_or_404(Intervention, id=id) form = NewPaymentForm(request.POST or None, instance=intervention, request=request) return form.process_request( request, msg_success=PAYMENT_ADDED, - redirect_url=reverse("intervention:detail", args=(intervention_id,)) + "#related_data" + redirect_url=reverse("intervention:detail", args=(id,)) + "#related_data" ) @login_required @default_group_required -def payment_remove_view(request: HttpRequest, id: str): +def payment_remove_view(request: HttpRequest, id: str, payment_id: str): """ Renders a modal view for removing payments Args: request (HttpRequest): The incoming request - id (str): The payment's id + id (str): The intervention's id + payment_id (str): The payment's id Returns: """ - payment = get_object_or_404(Payment, id=id) - form = RemoveModalForm(request.POST or None, instance=payment, request=request) + intervention = get_object_or_404(Intervention, id=id) + payment = get_object_or_404(Payment, id=payment_id) + form = PaymentRemoveModalForm(request.POST or None, instance=intervention, payment=payment, request=request) return form.process_request( request=request, msg_success=PAYMENT_REMOVED, diff --git a/ema/views.py b/ema/views.py index 82bfcdc0..5f60c7a2 100644 --- a/ema/views.py +++ b/ema/views.py @@ -6,7 +6,8 @@ from django.shortcuts import render, get_object_or_404, redirect from django.urls import reverse from django.utils.translation import gettext_lazy as _ -from compensation.forms.modalForms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm +from compensation.forms.modalForms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm, \ + CompensationActionRemoveModalForm, CompensationStateRemoveModalForm from compensation.models import CompensationAction, CompensationState from ema.forms import NewEmaForm, EditEmaForm, NewEmaDocumentForm from ema.tables import EmaTable @@ -425,8 +426,9 @@ def state_remove_view(request: HttpRequest, id: str, state_id: str): Returns: """ + ema = get_object_or_404(Ema, id=id) state = get_object_or_404(CompensationState, id=state_id) - form = RemoveModalForm(request.POST or None, instance=state, request=request) + form = CompensationStateRemoveModalForm(request.POST or None, instance=ema, state=state, request=request) return form.process_request( request, msg_success=COMPENSATION_STATE_REMOVED, @@ -448,8 +450,9 @@ def action_remove_view(request: HttpRequest, id: str, action_id: str): Returns: """ + ema = get_object_or_404(Ema, id=id) action = get_object_or_404(CompensationAction, id=action_id) - form = RemoveModalForm(request.POST or None, instance=action, request=request) + form = CompensationActionRemoveModalForm(request.POST or None, instance=ema, action=action, request=request) return form.process_request( request, msg_success=COMPENSATION_ACTION_REMOVED, diff --git a/intervention/forms/modalForms.py b/intervention/forms/modalForms.py index e44649da..d9112b1e 100644 --- a/intervention/forms/modalForms.py +++ b/intervention/forms/modalForms.py @@ -7,7 +7,7 @@ Created on: 27.09.21 """ from dal import autocomplete -from konova.utils.message_templates import DEDUCTION_ADDED, REVOCATION_ADDED +from konova.utils.message_templates import DEDUCTION_ADDED, REVOCATION_ADDED, DEDUCTION_REMOVED from user.models import User, UserActionLogEntry from django.db import transaction from django import forms @@ -16,7 +16,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 -from konova.forms import BaseModalForm, NewDocumentForm +from konova.forms import BaseModalForm, NewDocumentForm, RemoveModalForm from konova.utils.general import format_german_float from konova.utils.user_checks import is_default_group_only @@ -172,6 +172,23 @@ class NewRevocationModalForm(BaseModalForm): return revocation +class RevocationRemoveModalForm(RemoveModalForm): + """ Removing modal form for Revocation + + Can be used for anything, where removing shall be confirmed by the user a second time. + + """ + revocation = None + + def __init__(self, *args, **kwargs): + revocation = kwargs.pop("revocation", None) + self.revocation = revocation + super().__init__(*args, **kwargs) + + def save(self): + self.instance.remove_revocation(self) + + class CheckModalForm(BaseModalForm): """ The modal form for running a check on interventions and their compensations @@ -390,5 +407,25 @@ class NewDeductionModalForm(BaseModalForm): return deduction +class DeductionRemoveModalForm(RemoveModalForm): + """ Removing modal form for EcoAccountDeduction + + Can be used for anything, where removing shall be confirmed by the user a second time. + + """ + deduction = None + + def __init__(self, *args, **kwargs): + deduction = kwargs.pop("deduction", None) + self.deduction = deduction + super().__init__(*args, **kwargs) + + def save(self): + with transaction.atomic(): + self.deduction.intervention.mark_as_edited(self.user, edit_comment=DEDUCTION_REMOVED) + self.deduction.account.mark_as_edited(self.user, edit_comment=DEDUCTION_REMOVED) + self.deduction.delete() + + class NewInterventionDocumentForm(NewDocumentForm): document_model = InterventionDocument diff --git a/intervention/models/intervention.py b/intervention/models/intervention.py index 068594cb..79277339 100644 --- a/intervention/models/intervention.py +++ b/intervention/models/intervention.py @@ -16,7 +16,6 @@ from django.db import models, transaction from django.db.models import QuerySet from django.http import HttpRequest -from compensation.models import EcoAccountDeduction from intervention.managers import InterventionManager from intervention.models.legal import Legal from intervention.models.responsibility import Responsibility @@ -26,7 +25,8 @@ from konova.models import generate_document_file_upload_path, AbstractDocument, ShareableObjectMixin, \ RecordableObjectMixin, CheckableObjectMixin, GeoReferencedMixin from konova.settings import LANIS_LINK_TEMPLATE, LANIS_ZOOM_LUT, DEFAULT_SRID_RLP -from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, DEDUCTION_ADDED, DOCUMENT_REMOVED_TEMPLATE +from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, DOCUMENT_REMOVED_TEMPLATE, \ + PAYMENT_REMOVED, PAYMENT_ADDED, REVOCATION_REMOVED from user.models import UserActionLogEntry @@ -196,6 +196,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec comment=form_data.get("comment", None), intervention=self, ) + self.mark_as_edited(user, form.request, edit_comment=PAYMENT_ADDED) return pay def add_revocation(self, form): @@ -229,6 +230,21 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec ) return revocation + def remove_revocation(self, form): + """ Removes a revocation from the intervention + + Args: + form (RevocationRemoveModalForm): The form holding all relevant data + + Returns: + + """ + revocation = form.revocation + user = form.user + with transaction.atomic(): + revocation.delete() + self.mark_as_edited(user, request=form.request, edit_comment=REVOCATION_REMOVED) + def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None, reset_recorded: bool = True): """ In case the object or a related object changed, internal processes need to be started, such as unrecord and uncheck @@ -242,7 +258,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec Returns: """ - action = super().mark_as_edited(performing_user, edit_comment) + action = super().mark_as_edited(performing_user, edit_comment=edit_comment) if reset_recorded: self.unrecord(performing_user, request) if self.checked: @@ -289,6 +305,21 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec """ return reverse("intervention:share", args=(self.id, self.access_token)) + def remove_payment(self, form): + """ Removes a Payment from the intervention + + Args: + form (PaymentRemoveModalForm): The form holding all relevant data + + Returns: + + """ + payment = form.payment + user = form.user + with transaction.atomic(): + payment.delete() + self.mark_as_edited(user, request=form.request, edit_comment=PAYMENT_REMOVED) + class InterventionDocument(AbstractDocument): """ diff --git a/intervention/models/revocation.py b/intervention/models/revocation.py index da39b001..3f55bbf4 100644 --- a/intervention/models/revocation.py +++ b/intervention/models/revocation.py @@ -23,7 +23,7 @@ class Revocation(BaseResource): legal = models.ForeignKey("Legal", null=False, blank=False, on_delete=models.CASCADE, help_text="Refers to 'Widerspruch am'", related_name="revocations") comment = models.TextField(null=True, blank=True) - def delete(self, user=None, *args, **kwargs): + def delete(self, *args, **kwargs): # Make sure related objects are being removed as well try: self.document.delete(*args, **kwargs) @@ -31,9 +31,6 @@ class Revocation(BaseResource): # No file to delete pass - if user is not None: - self.legal.intervention.mark_as_edited(user, edit_comment=REVOCATION_REMOVED) - super().delete() @property diff --git a/intervention/templates/intervention/detail/includes/payments.html b/intervention/templates/intervention/detail/includes/payments.html index 53a17f8f..205755bc 100644 --- a/intervention/templates/intervention/detail/includes/payments.html +++ b/intervention/templates/intervention/detail/includes/payments.html @@ -56,7 +56,7 @@ {% if is_default_member and has_access %} - {% endif %} diff --git a/intervention/templates/intervention/detail/includes/revocation.html b/intervention/templates/intervention/detail/includes/revocation.html index 9fb2989d..d6b07b72 100644 --- a/intervention/templates/intervention/detail/includes/revocation.html +++ b/intervention/templates/intervention/detail/includes/revocation.html @@ -65,7 +65,7 @@ {% if is_default_member and has_access %} - {% endif %} diff --git a/intervention/tests/test_workflow.py b/intervention/tests/test_workflow.py index 7644051b..69f606f0 100644 --- a/intervention/tests/test_workflow.py +++ b/intervention/tests/test_workflow.py @@ -262,7 +262,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase): pre_payment_logs_count = self.intervention.log.count() # Create removing url for the payment - remove_url = reverse("compensation:pay:remove", args=(payment.id,)) + remove_url = reverse("compensation:pay:remove", args=(self.intervention.id, payment.id,)) post_data = { "confirm": True, } diff --git a/intervention/urls.py b/intervention/urls.py index 1c663124..7d6ff32f 100644 --- a/intervention/urls.py +++ b/intervention/urls.py @@ -28,7 +28,7 @@ urlpatterns = [ path('/report', report_view, name='report'), # Compensations - path('/remove/', remove_compensation_view, name='remove-compensation'), + path('/compensation//remove', remove_compensation_view, name='remove-compensation'), # Documents path('/document/new/', new_document_view, name='new-doc'), @@ -37,10 +37,10 @@ urlpatterns = [ # Deductions path('/deduction/new', new_deduction_view, name='new-deduction'), - path('/remove/', remove_deduction_view, name='remove-deduction'), + path('/deduction//remove', remove_deduction_view, name='remove-deduction'), # Revocation routes path('/revocation/new', new_revocation_view, name='new-revocation'), - path('revocation//remove', remove_revocation_view, name='remove-revocation'), + path('/revocation//remove', remove_revocation_view, name='remove-revocation'), path('revocation/', get_revocation_view, name='get-doc-revocation'), ] \ No newline at end of file diff --git a/intervention/views.py b/intervention/views.py index a518a9da..259f3e0f 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -6,7 +6,8 @@ from django.shortcuts import render from intervention.forms.forms import NewInterventionForm, EditInterventionForm from intervention.forms.modalForms import ShareModalForm, NewRevocationModalForm, \ - CheckModalForm, NewDeductionModalForm, NewInterventionDocumentForm + CheckModalForm, NewDeductionModalForm, NewInterventionDocumentForm, DeductionRemoveModalForm, \ + RevocationRemoveModalForm from intervention.models import Intervention, Revocation, InterventionDocument, RevocationDocument from intervention.tables import InterventionTable from konova.contexts import BaseContext @@ -340,7 +341,7 @@ def remove_view(request: HttpRequest, id: str): @login_required @default_group_required -def remove_revocation_view(request: HttpRequest, id: str): +def remove_revocation_view(request: HttpRequest, id: str, revocation_id: str): """ Renders a remove view for a revocation Args: @@ -350,13 +351,14 @@ def remove_revocation_view(request: HttpRequest, id: str): Returns: """ - obj = Revocation.objects.get(id=id) + intervention = get_object_or_404(Intervention, id=id) + revocation = get_object_or_404(Revocation, id=revocation_id) - form = RemoveModalForm(request.POST or None, instance=obj, request=request) + form = RevocationRemoveModalForm(request.POST or None, instance=intervention, revocation=revocation, request=request) return form.process_request( request, REVOCATION_REMOVED, - redirect_url=reverse("intervention:detail", args=(obj.intervention.id,)) + "#related_data" + redirect_url=reverse("intervention:detail", args=(intervention.id,)) + "#related_data" ) @@ -533,7 +535,7 @@ def remove_deduction_view(request: HttpRequest, id: str, deduction_id: str): except ObjectDoesNotExist: raise Http404("Unknown deduction") - form = RemoveModalForm(request.POST or None, instance=eco_deduction, request=request) + form = DeductionRemoveModalForm(request.POST or None, instance=intervention, deduction=eco_deduction, request=request) return form.process_request( request=request, msg_success=DEDUCTION_REMOVED, diff --git a/konova/forms.py b/konova/forms.py index 8b7539b3..66aeea70 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -327,7 +327,7 @@ class RemoveModalForm(BaseModalForm): self.instance.mark_as_deleted(self.user) else: # If the class does not provide restorable delete functionality, we must delete the entry finally - self.instance.delete(self.user) + self.instance.delete() class DeadlineRemoveModalForm(RemoveModalForm): diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index c25c2f113b0cf7f234e21d82feaf2dcc8f869568..7fe3a4ee71d0b17b766706edd33f285e920fe645 100644 GIT binary patch delta 3692 zcmXZedvJ|M7{~FIgj^(%5TX&JjYJ|u;?}x0LRCj-Bh-wJiWG@^ToP#_4o%zzlXf!H zwbRIym{NwgbOargL1tQ7)u=J0T8f&MX$kuM+5PLYyJz2ho_%)TbIzg7UWYe(?U@(i zX=RKF&om|s6Y(V+ge`F#hT~jJz*X2BYtRSJVl38SV|;{~-+;|9Y=SW%*Z~!%C$`2k z48TbfjK{Q~k;{NLmSPYtM~zoFccMT2qZo?cy8adC4Q#{sJyb#gSvFuY`q3YXF_?}@ za6Sg&+ANPTku)|jpumUF7f+)C)}eOr6Dsg+)PoJE9r%A>cOHhSTm))<57fGEU<78N zc3zCZSb<7-yN8ArI*!Whobv`MU<1Zu@I+(U;cKXc#-I|-#U@yQO3Z^wWHl;q6?)@w z)DfISRixhOxk*E3bq{rh&rlP6CfSK?Pz!cIjSoN_&1m=e6dXl=j`K9Gryn`l&fkx^ zGv}}=UPD#r4w9h9G|*5+;n~(GRO#cfF?M(3y-^iPMP1IZsCl`l3Kn7vF2Tl)jHyOd z;TlZFGpHRu zL2@v`Q|U`zG*r?f*cR(hncqc~>@fyllWF$Sgko>{T~L9t(H{$) zrRYn44XRQVs7mfat-BX>32V`#j4sgd!g|z$*HD+{7QTviPywQ++q3I}T3`Sw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^shzOh3^>)OOLr8tll!Oyp5SC& z@1xHCA;#eoT!Ar#j`I;#;wl`zjPu2l$XPm}%guM72ezd@2vw9$W*zv#cJpCZDP$hmro$*cUV^pOAi_961N3A;t6*$kj7TeP=xBY!Z z)L$h!!GLb%8B~A^*cq>2G(JKt6tU9mC>iy-4aJT)0(A%8M3s6ysv;Hk_r0hMokV?U zFQMZ8?9$Mg{fa929aP|dPyvHUPyxE5&U`THY^Pus%tGyG4eGh=*cFeWDtQTq<1^GB zwPEj=#HOO2bF*xt2o>;sRDdefYgL1x_z06R_+4{XQt>7FX{eoUMOAJm>O->|_1s}p zLf>K({%QL`#m~PVu9HYZnU6+I%(AY<=ZT<7T7wF34pqvFs6fACI6gq_D43h6ehlhJ zQc?33S&LBXZNxTu|98^REj@sG3+gZu&!ZN&haT8@wK=m0Yft3GaQa{h?#6O#LcKM4 z{DsQF9ToW7DYnEOn~ZVRL~Gwo)L%OvXa|O%5*UF>Y&3dfn*DvMbvo+L?<~~w z^HB41Y(F1c(=S9_w$*n0L)5$qRAN=G{h=DQ;67BqLw5WN)WqYc%XktK@o!ARZYAb_ z!8BCA1eH)7>h)~EG;~VMcVrUkEy>16oLEew8;weg!c*2;=tn diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index eb1b60a4..f7a36715 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -1896,7 +1896,7 @@ msgstr "Zustand hinzugefügt" #: konova/utils/message_templates.py:44 msgid "Added compensation action" -msgstr "Maßnahme hinzufügen" +msgstr "Maßnahme hinzugefügt" #: konova/utils/message_templates.py:47 msgid "Geometry conflict detected with {}"