[EcoAccount] See recorded state of withdraw #6

* adds prefiltering of withdraws --> excludes withdraws of as deleted flagged interventions
* renders intervention-recorded icon into eco account withdraws details view
* fixes bug in case of document deleting which does not contain any files
* renames RecordForm into RecordModalForm for more clarity
This commit is contained in:
mipel
2021-08-26 15:45:24 +02:00
parent 6655ed1f57
commit 8f641daee4
8 changed files with 46 additions and 15 deletions

View File

@@ -19,7 +19,7 @@ from compensation.tables import EcoAccountTable
from intervention.forms import NewWithdrawForm
from konova.contexts import BaseContext
from konova.decorators import any_group_check, default_group_required, conservation_office_group_required
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordForm
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordModalForm
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
from konova.utils.user_checks import in_group
@@ -97,6 +97,10 @@ def open_view(request: HttpRequest, id: str):
# Calculate rest of available surface for withdraws
available = acc.get_available_rest(as_percentage=True)
withdraws = acc.withdraws.filter(
intervention__deleted=None,
)
context = {
"obj": acc,
"geom_form": geom_form,
@@ -111,6 +115,7 @@ def open_view(request: HttpRequest, id: str):
"is_zb_member": in_group(_user, ZB_GROUP),
"is_ets_member": in_group(_user, ETS_GROUP),
"LANIS_LINK": acc.get_LANIS_link(),
"withdraws": withdraws,
}
context = BaseContext(request, context).context
return render(request, template, context)
@@ -200,7 +205,7 @@ def record_view(request: HttpRequest, id:str):
"""
acc = get_object_or_404(EcoAccount, id=id)
form = RecordForm(request.POST or None, instance=acc, user=request.user)
form = RecordModalForm(request.POST or None, instance=acc, user=request.user)
msg_succ = _("{} unrecorded") if acc.recorded else _("{} recorded")
msg_succ = msg_succ.format(acc.identifier)
return form.process_request(