From d5e23b420e766a0608eeeaab54aae6042c5fdd0b Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 2 Feb 2022 11:26:02 +0100 Subject: [PATCH] # 86 Viewport jump EcoAccount/EMA * adds direct jump of viewport on related-data action (create/delete) --- compensation/forms/forms.py | 10 ++-- compensation/models/eco_account.py | 10 ++++ compensation/tables.py | 4 +- .../detail/eco_account/includes/actions.html | 4 +- .../detail/eco_account/includes/controls.html | 14 ++--- .../eco_account/includes/deadlines.html | 4 +- .../eco_account/includes/deductions.html | 4 +- .../eco_account/includes/documents.html | 6 +- .../eco_account/includes/states-after.html | 4 +- .../eco_account/includes/states-before.html | 4 +- .../compensation/detail/eco_account/view.html | 42 ++++++------- compensation/tests/test_views.py | 28 ++++----- compensation/tests/test_workflow.py | 2 +- compensation/urls/eco_account.py | 40 +++++++------ compensation/urls/payment.py | 5 +- compensation/urls/urls.py | 4 +- compensation/views/eco_account.py | 59 ++++++++++++++----- ema/models/ema.py | 9 +++ .../ema/detail/includes/deadlines.html | 2 +- ema/templates/ema/detail/view.html | 37 ++++++------ ema/urls.py | 2 +- ema/views.py | 42 +++++++++++-- intervention/forms/modalForms.py | 6 +- intervention/models/intervention.py | 9 +++ .../detail/includes/deductions.html | 6 +- .../detail/includes/payments.html | 4 +- .../templates/intervention/report/report.html | 2 +- intervention/tests/test_workflow.py | 8 +-- intervention/urls.py | 2 +- konova/models/object.py | 9 +++ .../includes/quickstart/ecoaccounts.html | 6 +- konova/urls.py | 5 +- konova/views.py | 19 ------ templates/navbars/navbar.html | 2 +- 34 files changed, 247 insertions(+), 167 deletions(-) diff --git a/compensation/forms/forms.py b/compensation/forms/forms.py index 0970daad..7ac7f601 100644 --- a/compensation/forms/forms.py +++ b/compensation/forms/forms.py @@ -339,13 +339,13 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix super().__init__(*args, **kwargs) self.form_title = _("New Eco-Account") - self.action_url = reverse("compensation:acc-new") - self.cancel_redirect = reverse("compensation:acc-index") + self.action_url = reverse("compensation:acc:new") + self.cancel_redirect = reverse("compensation:acc:index") tmp = EcoAccount() identifier = tmp.generate_new_identifier() self.initialize_form_field("identifier", identifier) - self.fields["identifier"].widget.attrs["url"] = reverse_lazy("compensation:acc-new-id") + self.fields["identifier"].widget.attrs["url"] = reverse_lazy("compensation:acc:new-id") self.fields["title"].widget.attrs["placeholder"] = _("Eco-Account XY; Location ABC") def save(self, user: User, geom_form: SimpleGeomForm): @@ -402,8 +402,8 @@ class EditEcoAccountForm(NewEcoAccountForm): super().__init__(*args, **kwargs) self.form_title = _("Edit Eco-Account") - self.action_url = reverse("compensation:acc-edit", args=(self.instance.id,)) - self.cancel_redirect = reverse("compensation:acc-detail", args=(self.instance.id,)) + self.action_url = reverse("compensation:acc:edit", args=(self.instance.id,)) + self.cancel_redirect = reverse("compensation:acc:detail", args=(self.instance.id,)) # Initialize form data reg_date = self.instance.legal.registration_date diff --git a/compensation/models/eco_account.py b/compensation/models/eco_account.py index afe556f9..8e4d32e1 100644 --- a/compensation/models/eco_account.py +++ b/compensation/models/eco_account.py @@ -7,6 +7,8 @@ Created on: 16.11.21 """ import shutil +from django.urls import reverse + from user.models import User from django.core.exceptions import ValidationError from django.core.validators import MinValueValidator @@ -203,6 +205,14 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix is_ready = is_recorded return is_ready + def get_share_link(self): + """ Returns the share url for the object + + Returns: + + """ + return reverse("compensation:acc:share", args=(self.id, self.access_token)) + class EcoAccountDocument(AbstractDocument): """ diff --git a/compensation/tables.py b/compensation/tables.py index 9daf2b23..b78b5aa9 100644 --- a/compensation/tables.py +++ b/compensation/tables.py @@ -201,7 +201,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin): def __init__(self, request: HttpRequest, *args, **kwargs): self.title = _("Eco Accounts") - self.add_new_url = reverse("compensation:acc-new") + self.add_new_url = reverse("compensation:acc:new") qs = kwargs.get("queryset", None) self.filter = EcoAccountTableFilter( user=request.user, @@ -224,7 +224,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin): html = "" html += self.render_link( tooltip=_("Open {}").format(_("Eco-account")), - href=reverse("compensation:acc-detail", args=(record.id,)), + href=reverse("compensation:acc:detail", args=(record.id,)), txt=value, new_tab=False, ) diff --git a/compensation/templates/compensation/detail/eco_account/includes/actions.html b/compensation/templates/compensation/detail/eco_account/includes/actions.html index c5b9c1c1..67dd2bbf 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/actions.html +++ b/compensation/templates/compensation/detail/eco_account/includes/actions.html @@ -11,7 +11,7 @@
{% if is_default_member and has_access %} - @@ -58,7 +58,7 @@ {{ action.comment|default_if_none:"" }} {% if is_default_member and has_access %} - {% endif %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/controls.html b/compensation/templates/compensation/detail/eco_account/includes/controls.html index f43ddebe..fcc70dc2 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/controls.html +++ b/compensation/templates/compensation/detail/eco_account/includes/controls.html @@ -6,36 +6,36 @@ LANIS - + {% if has_access %} - {% if is_ets_member %} {% if obj.recorded %} - {% else %} - {% endif %} {% endif %} {% if is_default_member %} - + - - {% endif %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/deadlines.html b/compensation/templates/compensation/detail/eco_account/includes/deadlines.html index 4bf26df6..a1764df8 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/deadlines.html +++ b/compensation/templates/compensation/detail/eco_account/includes/deadlines.html @@ -11,7 +11,7 @@
{% if is_default_member and has_access %} - @@ -48,7 +48,7 @@ {{ deadline.comment }} {% if is_default_member and has_access %} - {% endif %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/deductions.html b/compensation/templates/compensation/detail/eco_account/includes/deductions.html index 16b9cb75..ca97f005 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/deductions.html +++ b/compensation/templates/compensation/detail/eco_account/includes/deductions.html @@ -11,7 +11,7 @@
{% if is_default_member and has_access %} - @@ -60,7 +60,7 @@ {{ deduction.created.timestamp|default_if_none:""|naturalday}} {% if is_default_member and has_access %} - {% endif %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/documents.html b/compensation/templates/compensation/detail/eco_account/includes/documents.html index bd371df2..f6376f46 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/documents.html +++ b/compensation/templates/compensation/detail/eco_account/includes/documents.html @@ -11,7 +11,7 @@
{% if is_default_member and has_access %} - @@ -39,14 +39,14 @@ {% for doc in obj.documents.all %} - + {{ doc.title }} {{ doc.comment }} {% if is_default_member and has_access %} - {% endif %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/states-after.html b/compensation/templates/compensation/detail/eco_account/includes/states-after.html index 70a36018..17e7d44a 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/states-after.html +++ b/compensation/templates/compensation/detail/eco_account/includes/states-after.html @@ -11,7 +11,7 @@
{% if is_default_member and has_access %} - @@ -61,7 +61,7 @@ {{ state.surface|floatformat:2 }} m² {% if is_default_member and has_access %} - {% endif %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/states-before.html b/compensation/templates/compensation/detail/eco_account/includes/states-before.html index 5482674a..3a1136ca 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/states-before.html +++ b/compensation/templates/compensation/detail/eco_account/includes/states-before.html @@ -11,7 +11,7 @@
{% if is_default_member and has_access %} - @@ -61,7 +61,7 @@ {{ state.surface|floatformat:2 }} m² {% if is_default_member and has_access %} - {% endif %} diff --git a/compensation/templates/compensation/detail/eco_account/view.html b/compensation/templates/compensation/detail/eco_account/view.html index 493a9292..033eda33 100644 --- a/compensation/templates/compensation/detail/eco_account/view.html +++ b/compensation/templates/compensation/detail/eco_account/view.html @@ -102,28 +102,30 @@

-
-
- {% include 'compensation/detail/eco_account/includes/states-before.html' %} +
- -
-
- {% include 'ema/detail/includes/states-before.html' %} +