EcoAccount withdraws

* adds functionality for withdraws from eco accounts in detail view of interventions and eco account as well
* adds get_surface() method to AbstractCompensation class to provide a simple getter for a sql calculation
* adds get_surface_withdraws() method to EcoAccount class to provide a simple getter for a sql calculation
* renames some routes to match coherent rout naming
* adds logic check on NewWithdrawForm
* renames templates/table directory to templates/form, since there are form-table templates inside --> more clarity
* adds new autocomplete routes to konova/urls.py for Interventions and EcoAccounts
* adds/updates translations
* adds/updates template comments
* updates requirements.txt
This commit is contained in:
mipel
2021-08-10 10:42:04 +02:00
parent 58510eee50
commit f8b3e5c8fd
21 changed files with 388 additions and 121 deletions

View File

@@ -7,6 +7,8 @@ Created on: 07.12.20
"""
from dal_select2.views import Select2QuerySetView
from compensation.models import EcoAccount
from intervention.models import Intervention
from organisation.models import Organisation
@@ -35,4 +37,40 @@ class NonOfficialOrganisationAutocomplete(Select2QuerySetView):
qs = qs.order_by(
"name"
)
return qs
class EcoAccountAutocomplete(Select2QuerySetView):
def get_queryset(self):
if self.request.user.is_anonymous:
return EcoAccount.objects.none()
qs = EcoAccount.objects.filter(
deleted=None,
recorded__isnull=False,
)
if self.q:
qs = qs.filter(
identifier__icontains=self.q
)
qs = qs.order_by(
"identifier"
)
return qs
class InterventionAutocomplete(Select2QuerySetView):
def get_queryset(self):
if self.request.user.is_anonymous:
return Intervention.objects.none()
qs = Intervention.objects.filter(
deleted=None,
users__in=[self.request.user],
)
if self.q:
qs = qs.filter(
identifier__icontains=self.q
)
qs = qs.order_by(
"identifier"
)
return qs

View File

@@ -3,6 +3,6 @@
{% block body %}
<div class="column">
{% include 'table/generic_table_form.html' %}
{% include 'form/generic_table_form.html' %}
</div>
{% endblock %}

View File

@@ -18,7 +18,8 @@ from django.contrib import admin
from django.urls import path, include
from simple_sso.sso_client.client import Client
from konova.autocompletes import OrganisationAutocomplete, NonOfficialOrganisationAutocomplete
from konova.autocompletes import OrganisationAutocomplete, NonOfficialOrganisationAutocomplete, EcoAccountAutocomplete, \
InterventionAutocomplete
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
from konova.views import logout_view, home_view, get_document_view, remove_document_view, remove_deadline_view
@@ -45,6 +46,8 @@ urlpatterns = [
# Autocomplete paths
path("atcmplt/orgs", OrganisationAutocomplete.as_view(), name="orgs-autocomplete"),
path("atcmplt/orgs/other", NonOfficialOrganisationAutocomplete.as_view(), name="other-orgs-autocomplete"),
path("atcmplt/eco-accounts", EcoAccountAutocomplete.as_view(), name="accounts-autocomplete"),
path("atcmplt/interventions", InterventionAutocomplete.as_view(), name="interventions-autocomplete"),
]
if DEBUG: