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:
@@ -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
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for withdraw in intervention.withdraws.all %}
|
||||
<tr {% if withdraw.account.deleted %}class="align-middle alert-danger" title="{% trans 'Eco-account deleted! Withdraw invalid!' %}" {% endif %}>
|
||||
<tr {% if withdraw.account.deleted %}class="align-middle alert-danger" title="{% trans 'Eco-account deleted! Withdraw invalid!' %}" {% elif not withdraw.account.recorded %}class="align-middle alert-danger" title="{% trans 'Eco-account not recorded! Withdraw invalid!' %}" {% endif %}>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'compensation:acc-open' withdraw.account.id %}">
|
||||
{% if withdraw.account.deleted %}
|
||||
{% if withdraw.account.deleted or not withdraw.account.recorded %}
|
||||
{% fa5_icon 'exclamation-triangle' %}
|
||||
{% endif %}
|
||||
{{ withdraw.account.identifier }}
|
||||
|
||||
Reference in New Issue
Block a user