# BaseModalFormView refactoring
* extends BaseModalFormView to hold general logic for processing GET and POST requests for BaseModalForm endpoints * refactors uuid check to use a specific parameter instead of kwargs * fixes css bug where modal form input elements would not be visible * refactors check view for intervention from function to class * refactors DeductionViews to inherit from extended BaseModalFormView
This commit is contained in:
@@ -172,7 +172,8 @@ class EditEcoAccountDeductionModalForm(NewEcoAccountDeductionModalForm):
|
||||
deduction = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.deduction = kwargs.pop("deduction", None)
|
||||
deduction_id = kwargs.pop("deduction_id", None)
|
||||
self.deduction = EcoAccountDeduction.objects.get(id=deduction_id)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Edit Deduction")
|
||||
form_data = {
|
||||
@@ -252,19 +253,20 @@ class RemoveEcoAccountDeductionModalForm(RemoveModalForm):
|
||||
Can be used for anything, where removing shall be confirmed by the user a second time.
|
||||
|
||||
"""
|
||||
deduction = None
|
||||
_DEDUCTION_OBJ = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
deduction = kwargs.pop("deduction", None)
|
||||
self.deduction = deduction
|
||||
deduction_id = kwargs.pop("deduction_id", None)
|
||||
deduction = EcoAccountDeduction.objects.get(id=deduction_id)
|
||||
self._DEDUCTION_OBJ = 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()
|
||||
self._DEDUCTION_OBJ.intervention.mark_as_edited(self.user, edit_comment=DEDUCTION_REMOVED)
|
||||
self._DEDUCTION_OBJ.account.mark_as_edited(self.user, edit_comment=DEDUCTION_REMOVED)
|
||||
self._DEDUCTION_OBJ.delete()
|
||||
|
||||
def check_for_recorded_instance(self):
|
||||
if self.deduction.intervention.is_recorded:
|
||||
if self._DEDUCTION_OBJ.intervention.is_recorded:
|
||||
self.block_form()
|
||||
|
||||
Reference in New Issue
Block a user