From 212985506830c50d4b9ec521e2d72d123c2984d5 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Tue, 11 Oct 2022 16:32:12 +0200 Subject: [PATCH] Fix for recorded deduction * fixes bug where deduction of a recorded intervention could be deleted from the eco account detail view * improves check_for_recorded_instance() logic * improves rendering of detail view on compensation-like objects to highlight missing data --- .../detail/compensation/includes/actions.html | 4 +++ .../compensation/includes/states-after.html | 4 +++ .../compensation/includes/states-before.html | 4 +++ .../detail/eco_account/includes/actions.html | 4 +++ .../eco_account/includes/states-after.html | 4 +++ .../eco_account/includes/states-before.html | 4 +++ .../ema/detail/includes/actions.html | 4 +++ .../ema/detail/includes/states-after.html | 4 +++ .../ema/detail/includes/states-before.html | 4 +++ intervention/forms/modals/deduction.py | 20 +++++++++++++- konova/forms/base_form.py | 25 ++++++++---------- konova/forms/modals/resubmission_form.py | 3 +++ locale/de/LC_MESSAGES/django.mo | Bin 45396 -> 45400 bytes locale/de/LC_MESSAGES/django.po | 4 +-- 14 files changed, 71 insertions(+), 17 deletions(-) diff --git a/compensation/templates/compensation/detail/compensation/includes/actions.html b/compensation/templates/compensation/detail/compensation/includes/actions.html index 87f49141..3fa4769b 100644 --- a/compensation/templates/compensation/detail/compensation/includes/actions.html +++ b/compensation/templates/compensation/detail/compensation/includes/actions.html @@ -74,6 +74,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/compensation/templates/compensation/detail/compensation/includes/states-after.html b/compensation/templates/compensation/detail/compensation/includes/states-after.html index 7faa0f1e..9c02978b 100644 --- a/compensation/templates/compensation/detail/compensation/includes/states-after.html +++ b/compensation/templates/compensation/detail/compensation/includes/states-after.html @@ -68,6 +68,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/compensation/templates/compensation/detail/compensation/includes/states-before.html b/compensation/templates/compensation/detail/compensation/includes/states-before.html index 23faed43..95917389 100644 --- a/compensation/templates/compensation/detail/compensation/includes/states-before.html +++ b/compensation/templates/compensation/detail/compensation/includes/states-before.html @@ -68,6 +68,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/actions.html b/compensation/templates/compensation/detail/eco_account/includes/actions.html index 8ae7c8fd..7a986535 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/actions.html +++ b/compensation/templates/compensation/detail/eco_account/includes/actions.html @@ -73,6 +73,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/states-after.html b/compensation/templates/compensation/detail/eco_account/includes/states-after.html index 4fce2f0f..05a05e31 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/states-after.html +++ b/compensation/templates/compensation/detail/eco_account/includes/states-after.html @@ -68,6 +68,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/states-before.html b/compensation/templates/compensation/detail/eco_account/includes/states-before.html index 1c6311cb..10b3f63b 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/states-before.html +++ b/compensation/templates/compensation/detail/eco_account/includes/states-before.html @@ -68,6 +68,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/ema/templates/ema/detail/includes/actions.html b/ema/templates/ema/detail/includes/actions.html index 0c352c11..91110701 100644 --- a/ema/templates/ema/detail/includes/actions.html +++ b/ema/templates/ema/detail/includes/actions.html @@ -71,6 +71,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/ema/templates/ema/detail/includes/states-after.html b/ema/templates/ema/detail/includes/states-after.html index 56e87be1..78cbee0a 100644 --- a/ema/templates/ema/detail/includes/states-after.html +++ b/ema/templates/ema/detail/includes/states-after.html @@ -66,6 +66,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/ema/templates/ema/detail/includes/states-before.html b/ema/templates/ema/detail/includes/states-before.html index 2fd7c359..fb29024a 100644 --- a/ema/templates/ema/detail/includes/states-before.html +++ b/ema/templates/ema/detail/includes/states-before.html @@ -66,6 +66,10 @@ {% endif %} + {% empty %} +
+ {% trans 'Missing' %} +
{% endfor %} diff --git a/intervention/forms/modals/deduction.py b/intervention/forms/modals/deduction.py index 130ef2f8..8e12a442 100644 --- a/intervention/forms/modals/deduction.py +++ b/intervention/forms/modals/deduction.py @@ -163,6 +163,10 @@ class NewEcoAccountDeductionModalForm(BaseModalForm): self.cleaned_data["account"].mark_as_edited(self.user, edit_comment=DEDUCTION_ADDED) return deduction + def check_for_recorded_instance(self): + # Ignore super() implementation + return + class EditEcoAccountDeductionModalForm(NewEcoAccountDeductionModalForm): deduction = None @@ -231,6 +235,16 @@ class EditEcoAccountDeductionModalForm(NewEcoAccountDeductionModalForm): old_account.send_notification_mail_on_deduction_change(data_changes) return deduction + def check_for_recorded_instance(self): + """ + Extension to super class base method + + Returns: + + """ + if self.deduction.intervention.is_recorded: + self.block_form() + class RemoveEcoAccountDeductionModalForm(RemoveModalForm): """ Removing modal form for EcoAccountDeduction @@ -249,4 +263,8 @@ class RemoveEcoAccountDeductionModalForm(RemoveModalForm): 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() \ No newline at end of file + self.deduction.delete() + + def check_for_recorded_instance(self): + if self.deduction.intervention.is_recorded: + self.block_form() diff --git a/konova/forms/base_form.py b/konova/forms/base_form.py index fb69999c..6b71c213 100644 --- a/konova/forms/base_form.py +++ b/konova/forms/base_form.py @@ -134,24 +134,21 @@ class BaseForm(forms.Form): Returns: """ - from intervention.forms.modals.deduction import NewEcoAccountDeductionModalForm, EditEcoAccountDeductionModalForm, \ - RemoveEcoAccountDeductionModalForm - from konova.forms.modals.resubmission_form import ResubmissionModalForm is_none = self.instance is None is_other_data_type = not isinstance(self.instance, BaseObject) - is_deduction_form_from_account = isinstance( - self, - ( - NewEcoAccountDeductionModalForm, - ResubmissionModalForm, - EditEcoAccountDeductionModalForm, - RemoveEcoAccountDeductionModalForm, - ) - ) and isinstance(self.instance, EcoAccount) - if is_none or is_other_data_type or is_deduction_form_from_account: + if is_none or is_other_data_type: # Do nothing return if self.instance.is_recorded: - self.template = "form/recorded_no_edit.html" + self.block_form() + + def block_form(self): + """ + Overwrites template, providing no actions + + Returns: + + """ + self.template = "form/recorded_no_edit.html" \ No newline at end of file diff --git a/konova/forms/modals/resubmission_form.py b/konova/forms/modals/resubmission_form.py index d1d846f6..97a52dcb 100644 --- a/konova/forms/modals/resubmission_form.py +++ b/konova/forms/modals/resubmission_form.py @@ -83,3 +83,6 @@ class ResubmissionModalForm(BaseModalForm): self.instance.resubmissions.add(self.resubmission) return self.resubmission + def check_for_recorded_instance(self): + # Ignore logic in super() implementation + return diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index fadbaa83a217916800a369beee95f18180e62dba..2c859d23da2b162fb6f1feede66394d6c5a486b5 100644 GIT binary patch delta 2596 zcmXZddra0<9LMp)MXnDJ7eNpNMldmWxOpQg7*nKVMG?_;>IQ^GPI4u#%cF}fTig;M zQB*XwAPB^zZZ<~fAI-%dQjy(sFt@B(W5i7UD0_eU9shZq?|IJeobUObbMV_4?<+Ij z!)0+Ee`CyKvoWFgBf9W6jK*6w4rwtaj5rQg;0knOC3<5M`r*6ii>JFp%Hkf}^; zt1)}=BnDu9oAHy%)lYc#GlcPK^?|qVLs;IR(u8z zVhR3@x%j|7XG0CB#K$lKJ(p<|(YTIUIJMK5Y|O$!+>Dy27jZ8$GQrmhzn5*KaS;CgKW@a&d^W=#!&+=p)$LMIf{njJEjVqR#YEye zn1+c5obO9e{ZHWp?m|^=!$D&rvD{jX(X4M8X=vg$)Pjet!>Gi@ZF~ha?srth7Erg| zi|uIv7slgaOvPN(?SB%rv0Bu8y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E_SqePGNqTw{G6V_DzqprMKDPzxTm_Mj3Qvhfe7alfG| zHi5eJ_fQM?*k&S5!#S9Py8Ta~Hdcn3ZzpPPW7mCc15Z z?>XX5n1Fi!epEuasIxCX9mNVv#MP(;x1#2M1LN_)5$dl?(M?AZ4x%#r3H9MP>g*%i z+!FgSK)eoT;z3kmy{PX7Q40;D=DmS>wiBogEopaONeSu>?QW<35720$BYk0 zeKxaD3zVQrya~gx95vx~oQ1WRid{CogbBoBsEznObjPJx3sDJfc4(-?J5USkLnY9R zTBrjxQ9o*jmrE&1i#Yn2J3e523^nhwsQD^Um8n4;c{6Gr=O~R78oj8AzCjP( zL!GJTxT_EUf9I$V<4|XvhPsrw_&NqK56|K*`~&qmUOHh6FV8fho@d5K#=NZe|0Ioc zI?m&R_&cUx+Q(c59nN?eB(*oxXnXs7#1e5izDQ1c{X zu-<)`0#9(Yi?YIp?u^To1465W`pcWWLmHcNLkE4$AU(}t6 z|Abe<`lf(}E<*ry<|U{z+lUdk4fW0)`}@79@hzwXI#G%Cq8Iyc5f0#D9LHSDJn2?; z11=%1Mn@l>wZ9m^RN@g#$Dl6vNHTCP@fNJcI#dP1Pw}4+6Hp86Mct7B>pAO}){CeL zUbgY@DeA9`uhOBNjN)XxX$Smiy@Mh2-$hLj)a{NBLB$d1!zk1dB-;L5)VzyOi7mDL z%TeXSWJgLEVTp5Q6E&GcDfC-@GbOX59Z(q7U0w#W0qkNs{dV7VxQao0rV5! z#kH7mn*R^D%b}q^iQiktQ13jn*FCEwyq|a(rs8wfJs3vZiF2?Yv+)}068k=N6VE`6 nE3ok@3?kOgD2=|wvs=qUwrno1sOq~~`&vp+Ro~;?QzrcfiHVtB diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 27f98ffc..a4a70839 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -1217,7 +1217,7 @@ msgstr "Keine Flächenmenge für Abbuchungen eingegeben. Bitte bearbeiten." #: intervention/templates/intervention/detail/view.html:100 #: intervention/templates/intervention/detail/view.html:104 msgid "Missing" -msgstr "fehlt" +msgstr "Fehlend" #: compensation/templates/compensation/detail/eco_account/view.html:71 #: ema/templates/ema/detail/view.html:57 @@ -2210,7 +2210,7 @@ msgstr "{} wurde erfolgreich vom Nutzer {} geprüft! {}" #: konova/utils/quality.py:32 msgid "missing" -msgstr "fehlt" +msgstr "fehlend" #: konova/views/home.py:78 templates/navbars/navbar.html:16 msgid "Home"