# NewCompensation EditCompensation view
* refactors new and edit compensation views from function to class based * adds checked property to compensation to return parent-intervention's checked info * fixes bug where compensation could be added to recorded intervention * updates translations
This commit is contained in:
@@ -168,6 +168,17 @@ class NewCompensationForm(AbstractCompensationForm,
|
||||
comp.log.add(action)
|
||||
return comp, action
|
||||
|
||||
def is_valid(self):
|
||||
valid = super().is_valid()
|
||||
intervention = self.cleaned_data.get("intervention", None)
|
||||
valid &= not intervention.is_recorded
|
||||
if not valid:
|
||||
self.add_error(
|
||||
"intervention",
|
||||
_("This intervention is currently recorded. You cannot add further compensations as long as it is recorded.")
|
||||
)
|
||||
return valid
|
||||
|
||||
def save(self, user: User, geom_form: SimpleGeomForm):
|
||||
with transaction.atomic():
|
||||
comp, action = self.__create_comp(user)
|
||||
|
||||
Reference in New Issue
Block a user