Eco Accounts

* adds related eco account withdraw detail view to intervention detail view
* adds new route for removing withdraws using RemoveModalForm
* adds EcoAccountWithdraw model
* adds admin interfaces for EcoAccount and EcoAccountWithdraw
* adds message_templates.py to konova/utils for reusable messages
* splits related-documents.html and related-objects.html into separate templates for each related object type: compensations.html, documents.html, eco-account-withdraws.html and payments.html
* adds translations
This commit is contained in:
mipel
2021-08-02 10:14:34 +02:00
parent 221f7dfb79
commit 98de05089e
16 changed files with 412 additions and 209 deletions

View File

@@ -0,0 +1,49 @@
{% load i18n l10n fontawesome_5 %}
<div id="related-compensations" class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.compensations.count}}</span>
{% trans 'Compensations' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<a href="{% url 'compensation:new' %}" title="{% trans 'Add new compensation' %}">
<button class="btn btn-outline-default">
{% fa5_icon 'plus' %}
{% fa5_icon 'leaf' %}
</button>
</a>
</div>
</div>
</div>
</div>
<div class="card-body scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Identifier' %}
</th>
<th scope="col">
{% trans 'Title' %}
</th>
</tr>
</thead>
<tbody>
{% for comp in intervention.compensations.all %}
<tr>
<td class="align-middle">
<a href="{% url 'compensation:open' comp.id %}">
{{ comp.identifier }}
</a>
</td>
<td class="align-middle">{{ comp.title }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

View File

@@ -0,0 +1,55 @@
{% load i18n l10n fontawesome_5 %}
<div id="related-documents" class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.documents.count}}</span>
{% trans 'Documents' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<button class="btn btn-outline-default btn-modal" data-form-url="{% url 'intervention:new-doc' intervention.id %}" title="{% trans 'Add new document' %}">
{% fa5_icon 'plus' %}
{% fa5_icon 'file' %}
</button>
</div>
</div>
</div>
</div>
<div class="card-body scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Title' %}
</th>
<th scope="col">
{% trans 'Comment' %}
</th>
<th scope="col">
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
{% for doc in intervention.documents.all %}
<tr>
<td class="align-middle">
<a href="{% url 'doc-open' doc.id %}">
{{ doc.title }}
</a>
</td>
<td class="align-middle">{{ doc.comment }}</td>
<td>
<button data-form-url="{% url 'doc-remove' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
{% fa5_icon 'trash' %}
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

View File

@@ -0,0 +1,57 @@
{% load i18n l10n fontawesome_5 %}
<div id="related-eco-account-withdraws" class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.eco_withdraws.count}}</span>
{% trans 'Eco Account Withdraws' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<a href="{% url 'compensation:new' %}" title="{% trans 'Add new withdraw' %}">
<button class="btn btn-outline-default">
{% fa5_icon 'plus' %}
{% fa5_icon 'tree' %}
</button>
</a>
</div>
</div>
</div>
</div>
<div class="card-body scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Account Identifier' %}
</th>
<th scope="col">
{% trans 'Amount' %}
</th>
<th scope="col">
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
{% for withdraw in intervention.eco_withdraws.all %}
<tr>
<td class="align-middle">
<a href="{% url 'compensation:acc-open' withdraw.account.id %}">
{{ withdraw.account.identifier }}
</a>
</td>
<td class="align-middle">{{ withdraw.amount }} %</td>
<td>
<button data-form-url="{% url 'compensation:withdraw-remove' withdraw.account.id withdraw.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove Withdraw' %}">
{% fa5_icon 'trash' %}
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

View File

@@ -0,0 +1,59 @@
{% load i18n l10n fontawesome_5 %}
<div id="related-payments" class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.payments.count}}</span>
{% trans 'Payments' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:pay-new' intervention.id %}" title="{% trans 'Add new payment' %}">
{% fa5_icon 'plus' %}
{% fa5_icon 'money-bill-wave' %}
</button>
</div>
</div>
</div>
</div>
<div class="card-body scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Amount' context 'money' %}
</th>
<th scope="col">
{% trans 'Due on' %}
</th>
<th scope="col">
{% trans 'Transfer comment' %}
</th>
<th scope="col">
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
{% for pay in intervention.payments.all %}
<tr>
<td class="align-middle">
<a href="{% url 'compensation:pay-open' pay.id %}">
{{ pay.amount|floatformat:2 }} €
</a>
</td>
<td class="align-middle">{{ pay.due_on }}</td>
<td class="align-middle">{{ pay.comment }}</td>
<td>
<button data-form-url="{% url 'compensation:pay-remove' pay.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove payment' %}">
{% fa5_icon 'trash' %}
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

View File

@@ -1,59 +0,0 @@
{% load i18n l10n fontawesome_5 %}
<div id="related-documents" class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.documents.count}}</span>
{% trans 'Documents' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<button class="btn btn-outline-default btn-modal" data-form-url="{% url 'intervention:new-doc' intervention.id %}" title="{% trans 'Add new document' %}">
{% fa5_icon 'plus' %}
{% fa5_icon 'file' %}
</button>
</div>
</div>
</div>
</div>
<div class="card-body scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Title' %}
</th>
<th scope="col">
{% trans 'Comment' %}
</th>
<th scope="col">
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
{% for doc in intervention.documents.all %}
<tr>
<td class="align-middle">
<a href="{% url 'doc-open' doc.id %}">
{{ doc.title }}
</a>
</td>
<td class="align-middle">{{ doc.comment }}</td>
<td>
<button data-form-url="{% url 'doc-remove' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
{% fa5_icon 'trash' %}
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@@ -1,113 +0,0 @@
{% load i18n l10n fontawesome_5 %}
<div id="related-objects" class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div id="related-compensations" class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.compensations.count}}</span>
{% trans 'Compensations' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<a href="{% url 'compensation:new' %}" title="{% trans 'Add new compensation' %}">
<button class="btn btn-outline-default">
{% fa5_icon 'plus' %}
{% fa5_icon 'leaf' %}
</button>
</a>
</div>
</div>
</div>
</div>
<div class="card-body scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Identifier' %}
</th>
<th scope="col">
{% trans 'Title' %}
</th>
</tr>
</thead>
<tbody>
{% for comp in intervention.compensations.all %}
<tr>
<td class="align-middle">
<a href="{% url 'compensation:open' comp.id %}">
{{ comp.identifier }}
</a>
</td>
<td class="align-middle">{{ comp.title }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div id="related-payments" class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.payments.count}}</span>
{% trans 'Payments' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:pay-new' intervention.id %}" title="{% trans 'Add new payment' %}">
{% fa5_icon 'plus' %}
{% fa5_icon 'money-bill-wave' %}
</button>
</div>
</div>
</div>
</div>
<div class="card-body scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Amount' %}
</th>
<th scope="col">
{% trans 'Due on' %}
</th>
<th scope="col">
{% trans 'Transfer comment' %}
</th>
<th scope="col">
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
{% for pay in intervention.payments.all %}
<tr>
<td class="align-middle">
<a href="{% url 'compensation:pay-open' pay.id %}">
{{ pay.amount|floatformat:2 }} €
</a>
</td>
<td class="align-middle">{{ pay.due_on }}</td>
<td class="align-middle">{{ pay.comment }}</td>
<td>
<button data-form-url="{% url 'compensation:pay-remove' pay.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove payment' %}">
{% fa5_icon 'trash' %}
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@@ -146,8 +146,22 @@
</div>
<hr>
{% include 'intervention/detail/related-objects.html' %}
{% include 'intervention/detail/related-documents.html' %}
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
{% include 'intervention/detail/includes/compensations.html' %}
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
{% include 'intervention/detail/includes/payments.html' %}
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
{% include 'intervention/detail/includes/eco-account-withdraws.html' %}
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
{% include 'intervention/detail/includes/documents.html' %}
</div>
</div>
{% with 'btn-modal' as btn_class %}

View File

@@ -10,6 +10,7 @@ from intervention.tables import InterventionTable
from konova.contexts import BaseContext
from konova.decorators import *
from konova.forms import RemoveForm, SimpleGeomForm, NewDocumentForm
from konova.utils.message_templates import FORM_INVALID
@login_required
@@ -98,7 +99,7 @@ def new_document_view(request: HttpRequest, id: str):
else:
messages.info(
request,
_("There was an error on this form.")
FORM_INVALID
)
return redirect(request.META.get("HTTP_REFERER", "home"))
elif request.method == "GET":