#140 Enhancements

* fixes InterventionAutocomplete bug, where team-shared entries would not pop up as valid option
* fixes bug where form opening for new compensation without direct intervention link resulted in 404
* adds intervention-recorded check on deduction forms: Form is invalid if intervention is currently recorded and therefore blocked for any editing
* extends basic check_for_recorded_instance() method to let some forms pass, e.g. deduction related forms on ecoaccounts which only have a reason to be rendered IF the entry is recorded
* adds/updates translations
This commit is contained in:
2022-04-19 13:37:29 +02:00
parent 090f6faa4e
commit 3b36193566
6 changed files with 164 additions and 122 deletions

View File

@@ -427,13 +427,22 @@ class NewDeductionModalForm(BaseModalForm):
"""
super_result = super().is_valid()
acc = self.cleaned_data["account"]
intervention = self.cleaned_data["intervention"]
objects_valid = True
if not acc.recorded:
self.add_error(
"account",
_("Eco-account {} is not recorded yet. You can only deduct from recorded accounts.").format(acc.identifier)
)
return False
objects_valid = False
if intervention.is_recorded:
self.add_error(
"intervention",
_("Intervention {} is currently recorded. To change any data on it, the entry must be unrecorded.").format(intervention.identifier)
)
objects_valid = False
rest_surface = self._get_available_surface(acc)
form_surface = float(self.cleaned_data["surface"])
@@ -447,7 +456,7 @@ class NewDeductionModalForm(BaseModalForm):
format_german_float(rest_surface),
),
)
return is_valid_surface and super_result
return is_valid_surface and objects_valid and super_result
def __create_deduction(self):
""" Creates the deduction