EcoAccount detail view

* adds record control button
* adds html markup for invalid withdraws (unrecorded account)
* adds constraint to is_valid() method of NewWithdrawForm for checking whether the selected account for a withdraw is recorded or not
* adds/updates translations
This commit is contained in:
mipel
2021-08-10 14:15:42 +02:00
parent 09d7cad8c8
commit bd2413d63c
6 changed files with 139 additions and 111 deletions
+9 -1
View File
@@ -439,7 +439,7 @@ class NewWithdrawForm(BaseModalForm):
label=_("Eco-account"),
label_suffix="",
help_text=_("Only recorded accounts can be selected for withdraws"),
queryset=EcoAccount.objects.filter(deleted=None, recorded__isnull=False),
queryset=EcoAccount.objects.filter(deleted=None),
widget=autocomplete.ModelSelect2(
url="accounts-autocomplete",
attrs={
@@ -506,6 +506,14 @@ class NewWithdrawForm(BaseModalForm):
else:
acc = self.instance
if not acc.recorded:
self.add_error(
"account",
_("Eco-account {} is not recorded yet. You can only withdraw from recorded accounts.").format(acc.identifier)
)
return False
# Calculate valid surface
sum_surface = acc.get_surface()
sum_surface_withdraws = acc.get_surface_withdraws()
rest_surface = sum_surface - sum_surface_withdraws