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
This commit is contained in:
@@ -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()
|
||||
self.deduction.delete()
|
||||
|
||||
def check_for_recorded_instance(self):
|
||||
if self.deduction.intervention.is_recorded:
|
||||
self.block_form()
|
||||
|
||||
Reference in New Issue
Block a user