diff --git a/compensation/templates/compensation/detail/includes/actions.html b/compensation/templates/compensation/detail/compensation/includes/actions.html
similarity index 100%
rename from compensation/templates/compensation/detail/includes/actions.html
rename to compensation/templates/compensation/detail/compensation/includes/actions.html
diff --git a/compensation/templates/compensation/detail/includes/controls.html b/compensation/templates/compensation/detail/compensation/includes/controls.html
similarity index 100%
rename from compensation/templates/compensation/detail/includes/controls.html
rename to compensation/templates/compensation/detail/compensation/includes/controls.html
diff --git a/compensation/templates/compensation/detail/includes/deadlines.html b/compensation/templates/compensation/detail/compensation/includes/deadlines.html
similarity index 100%
rename from compensation/templates/compensation/detail/includes/deadlines.html
rename to compensation/templates/compensation/detail/compensation/includes/deadlines.html
diff --git a/compensation/templates/compensation/detail/includes/documents.html b/compensation/templates/compensation/detail/compensation/includes/documents.html
similarity index 100%
rename from compensation/templates/compensation/detail/includes/documents.html
rename to compensation/templates/compensation/detail/compensation/includes/documents.html
diff --git a/compensation/templates/compensation/detail/includes/states-after.html b/compensation/templates/compensation/detail/compensation/includes/states-after.html
similarity index 100%
rename from compensation/templates/compensation/detail/includes/states-after.html
rename to compensation/templates/compensation/detail/compensation/includes/states-after.html
diff --git a/compensation/templates/compensation/detail/includes/states-before.html b/compensation/templates/compensation/detail/compensation/includes/states-before.html
similarity index 100%
rename from compensation/templates/compensation/detail/includes/states-before.html
rename to compensation/templates/compensation/detail/compensation/includes/states-before.html
diff --git a/compensation/templates/compensation/detail/view.html b/compensation/templates/compensation/detail/compensation/view.html
similarity index 89%
rename from compensation/templates/compensation/detail/view.html
rename to compensation/templates/compensation/detail/compensation/view.html
index a2b6ad81..310e7eb0 100644
--- a/compensation/templates/compensation/detail/view.html
+++ b/compensation/templates/compensation/detail/compensation/view.html
@@ -12,7 +12,7 @@
{% trans 'Compensation' %} {{obj.identifier}}
- {% include 'compensation/detail/includes/controls.html' %}
+ {% include 'compensation/detail/compensation/includes/controls.html' %}
@@ -91,23 +91,23 @@
- {% include 'compensation/detail/includes/states-before.html' %}
+ {% include 'compensation/detail/compensation/includes/states-before.html' %}
- {% include 'compensation/detail/includes/states-after.html' %}
+ {% include 'compensation/detail/compensation/includes/states-after.html' %}
- {% include 'compensation/detail/includes/actions.html' %}
+ {% include 'compensation/detail/compensation/includes/actions.html' %}
- {% include 'compensation/detail/includes/deadlines.html' %}
+ {% include 'compensation/detail/compensation/includes/deadlines.html' %}
- {% include 'compensation/detail/includes/documents.html' %}
+ {% include 'compensation/detail/compensation/includes/documents.html' %}
+ {% if is_default_member and has_access %}
+
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
+
\ No newline at end of file
diff --git a/compensation/templates/compensation/detail/eco_account/includes/states-after.html b/compensation/templates/compensation/detail/eco_account/includes/states-after.html
new file mode 100644
index 00000000..da88db0e
--- /dev/null
+++ b/compensation/templates/compensation/detail/eco_account/includes/states-after.html
@@ -0,0 +1,62 @@
+{% load i18n l10n fontawesome_5 %}
+
+
+
+
+
+ {{obj.after_states.count}}
+ {% trans 'States after' %}
+
+
+
+
+ {% if is_default_member and has_access %}
+
+ {% endif %}
+
+
+
+
+
+ {% if sum_before_states > sum_after_states %}
+
+ {% trans 'Missing surfaces according to states before: ' %}{{ diff_states|floatformat:2 }} m²
+
+ {% endif %}
+
+
+
+
+ {% trans 'Biotope type' %}
+
+
+ {% trans 'Surface' %}
+
+
+ {% trans 'Action' %}
+
+
+
+
+ {% for state in after_states %}
+
+
+ {{ state.biotope_type }}
+
+
{{ state.surface|floatformat:2 }} m²
+
+ {% if is_default_member and has_access %}
+
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
+
\ No newline at end of file
diff --git a/compensation/templates/compensation/detail/eco_account/includes/states-before.html b/compensation/templates/compensation/detail/eco_account/includes/states-before.html
new file mode 100644
index 00000000..33591509
--- /dev/null
+++ b/compensation/templates/compensation/detail/eco_account/includes/states-before.html
@@ -0,0 +1,62 @@
+{% load i18n l10n fontawesome_5 %}
+
+
+
+
+
+ {{obj.before_states.count}}
+ {% trans 'States before' %}
+
+
+
+
+ {% if is_default_member and has_access %}
+
+ {% endif %}
+
+
+
+
+
+ {% if sum_before_states < sum_after_states %}
+
+ {% trans 'Missing surfaces according to states after: ' %}{{ diff_states|floatformat:2 }} m²
+
+ {% endif %}
+
+
+
+
+ {% trans 'Biotope type' %}
+
+
+ {% trans 'Surface' %}
+
+
+ {% trans 'Action' %}
+
+
+
+
+ {% for state in before_states %}
+
+
+ {{ state.biotope_type }}
+
+
{{ state.surface|floatformat:2 }} m²
+
+ {% if is_default_member and has_access %}
+
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
+
\ No newline at end of file
diff --git a/compensation/templates/compensation/detail/eco_account/view.html b/compensation/templates/compensation/detail/eco_account/view.html
index e42a9b32..098d7a3d 100644
--- a/compensation/templates/compensation/detail/eco_account/view.html
+++ b/compensation/templates/compensation/detail/eco_account/view.html
@@ -12,7 +12,7 @@
{% trans 'Eco-account' %} {{obj.identifier}}
- {% include 'compensation/detail/includes/controls.html' %}
+ {% include 'compensation/detail/eco_account/includes/controls.html' %}
@@ -77,23 +77,23 @@
- {% include 'compensation/detail/includes/states-before.html' %}
+ {% include 'compensation/detail/eco_account/includes/states-before.html' %}
- {% include 'compensation/detail/includes/states-after.html' %}
+ {% include 'compensation/detail/eco_account/includes/states-after.html' %}
- {% include 'compensation/detail/includes/actions.html' %}
+ {% include 'compensation/detail/eco_account/includes/actions.html' %}
- {% include 'compensation/detail/includes/deadlines.html' %}
+ {% include 'compensation/detail/eco_account/includes/deadlines.html' %}
- {% include 'compensation/detail/includes/documents.html' %}
+ {% include 'compensation/detail/eco_account/includes/documents.html' %}
{% include 'compensation/detail/eco_account/includes/withdraws.html' %}
diff --git a/compensation/urls.py b/compensation/urls.py
index 0014e933..4600e850 100644
--- a/compensation/urls.py
+++ b/compensation/urls.py
@@ -20,11 +20,19 @@ urlpatterns_payment = [
]
urlaptterns_eco_acc = [
- path("acc/", eco_account_views.account_index_view, name="acc-index"),
- path('acc/new/', eco_account_views.account_new_view, name='acc-new'),
- path('acc/', eco_account_views.account_open_view, name='acc-open'),
- path('acc//edit', eco_account_views.account_edit_view, name='acc-edit'),
- path('acc//remove', eco_account_views.account_remove_view, name='acc-remove'),
+ path("acc/", eco_account_views.index_view, name="acc-index"),
+ path('acc/new/', eco_account_views.new_view, name='acc-new'),
+ path('acc/', eco_account_views.open_view, name='acc-open'),
+ path('acc//log', eco_account_views.log_view, name='acc-log'),
+ path('acc//edit', eco_account_views.edit_view, name='acc-edit'),
+ path('acc//remove', eco_account_views.remove_view, name='acc-remove'),
+ path('acc//state/new', eco_account_views.state_new_view, name='acc-new-state'),
+ path('acc//action/new', eco_account_views.action_new_view, name='acc-new-action'),
+ path('acc//deadline/new', eco_account_views.deadline_new_view, name="acc-new-deadline"),
+
+ # Documents
+ # Document remove route can be found in konova/urls.py
+ path('acc//document/new/', eco_account_views.new_document_view, name='acc-new-doc'),
# Eco-account withdraws
path('acc//remove/', eco_account_views.withdraw_remove_view, name='withdraw-remove'),
@@ -43,6 +51,7 @@ urlpatterns_compensation = [
path('/deadline/new', compensation_views.deadline_new_view, name="new-deadline"),
# Documents
+ # Document remove route can be found in konova/urls.py
path('/document/new/', compensation_views.new_document_view, name='new-doc'),
# Generic state routes
diff --git a/compensation/views/compensation_views.py b/compensation/views/compensation_views.py
index 1ed61165..900827be 100644
--- a/compensation/views/compensation_views.py
+++ b/compensation/views/compensation_views.py
@@ -67,7 +67,7 @@ def open_view(request: HttpRequest, id: str):
Returns:
"""
- template = "compensation/detail/view.html"
+ template = "compensation/detail/compensation/view.html"
comp = get_object_or_404(Compensation, id=id)
geom_form = SimpleGeomForm(instance=comp)
_user = request.user
diff --git a/compensation/views/eco_account_views.py b/compensation/views/eco_account_views.py
index 5552db94..d0ba4a9f 100644
--- a/compensation/views/eco_account_views.py
+++ b/compensation/views/eco_account_views.py
@@ -6,24 +6,26 @@ Created on: 09.08.21
"""
from django.db.models import Sum
+from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpRequest, Http404
from django.shortcuts import render, get_object_or_404
+from compensation.forms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm
from compensation.models import EcoAccount
from compensation.tables import EcoAccountTable
from konova.contexts import BaseContext
from konova.decorators import any_group_check, default_group_required
-from konova.forms import RemoveModalForm, SimpleGeomForm
+from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
from konova.utils.user_checks import in_group
@login_required
@any_group_check
-def account_index_view(request: HttpRequest):
+def index_view(request: HttpRequest):
"""
Renders the index view for eco accounts
@@ -51,21 +53,21 @@ def account_index_view(request: HttpRequest):
@login_required
@default_group_required
-def account_new_view(request: HttpRequest):
+def new_view(request: HttpRequest):
# ToDo
pass
@login_required
@default_group_required
-def account_edit_view(request: HttpRequest, id: str):
+def edit_view(request: HttpRequest, id: str):
# ToDo
pass
@login_required
@any_group_check
-def account_open_view(request: HttpRequest, id: str):
+def open_view(request: HttpRequest, id: str):
""" Renders a detail view for a compensation
Args:
@@ -115,11 +117,23 @@ def account_open_view(request: HttpRequest, id: str):
@login_required
-def account_remove_view(request: HttpRequest, id: str):
- # ToDo
- pass
+def remove_view(request: HttpRequest, id: str):
+ """ Renders a modal view for removing the eco account
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The account's id
+ Returns:
+
+ """
+ acc = get_object_or_404(EcoAccount, id=id)
+ form = RemoveModalForm(request.POST or None, instance=acc, user=request.user)
+ return form.process_request(
+ request=request,
+ msg_success=_("Eco-account removed"),
+ redirect_url=reverse("compensation:acc-index"),
+ )
@login_required
@@ -147,3 +161,102 @@ def withdraw_remove_view(request: HttpRequest, id: str, withdraw_id: str):
msg_success=_("Withdraw removed")
)
+
+@login_required
+@default_group_required
+def log_view(request: HttpRequest, id: str):
+ """ Renders a log view using modal
+
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The eco acount's id
+
+ Returns:
+
+ """
+ comp = get_object_or_404(EcoAccount, id=id)
+ template = "modal/modal_generic.html"
+ body_template = "log.html"
+
+ context = {
+ "modal_body_template": body_template,
+ "log": comp.log.all().order_by("-timestamp"),
+ "modal_title": _("Log"),
+ }
+ context = BaseContext(request, context).context
+ return render(request, template, context)
+
+
+@login_required
+def state_new_view(request: HttpRequest, id: str):
+ """ Renders a form for adding new states for an eco account
+
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The account's id to which the new state will be related
+
+ Returns:
+
+ """
+ acc = get_object_or_404(EcoAccount, id=id)
+ form = NewStateModalForm(request.POST or None, instance=acc, user=request.user)
+ return form.process_request(
+ request,
+ msg_success=_("State added")
+ )
+
+
+@login_required
+def action_new_view(request: HttpRequest, id: str):
+ """ Renders a form for adding new actions for an eco account
+
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The account's id to which the new state will be related
+
+ Returns:
+
+ """
+ acc = get_object_or_404(EcoAccount, id=id)
+ form = NewActionModalForm(request.POST or None, instance=acc, user=request.user)
+ return form.process_request(
+ request,
+ msg_success=_("Action added")
+ )
+
+
+@login_required
+def deadline_new_view(request: HttpRequest, id: str):
+ """ Renders a form for adding new states for an eco account
+
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The account's id to which the new state will be related
+
+ Returns:
+
+ """
+ acc = get_object_or_404(EcoAccount, id=id)
+ form = NewDeadlineModalForm(request.POST or None, instance=acc, user=request.user)
+ return form.process_request(
+ request,
+ msg_success=_("Deadline added")
+ )
+
+
+@login_required
+def new_document_view(request: HttpRequest, id: str):
+ """ Renders a form for uploading new documents
+
+ Args:
+ request (HttpRequest): The incoming request
+ id (str): The account's id to which the new document will be related
+ Returns:
+
+ """
+ acc = get_object_or_404(EcoAccount, id=id)
+ form = NewDocumentForm(request.POST or None, request.FILES or None, instance=acc, user=request.user)
+ return form.process_request(
+ request,
+ msg_success=_("Document added")
+ )
\ No newline at end of file
diff --git a/intervention/templates/intervention/detail/includes/withdraws.html b/intervention/templates/intervention/detail/includes/withdraws.html
index 24199e40..8a170bd7 100644
--- a/intervention/templates/intervention/detail/includes/withdraws.html
+++ b/intervention/templates/intervention/detail/includes/withdraws.html
@@ -39,9 +39,12 @@
{% for withdraw in intervention.withdraws.all %}
-