From 09d7cad8c8503e1a9daba721913326c76ee990f9 Mon Sep 17 00:00:00 2001 From: mipel Date: Tue, 10 Aug 2021 13:57:03 +0200 Subject: [PATCH] LANIS Link * adds LANIS link getter to Intervention, Compensation and EcoAccount for creating a usable link to LANIS * adds/updates translations --- compensation/models.py | 45 ++++++++++++++++++ .../compensation/includes/controls.html | 2 +- .../detail/eco_account/includes/controls.html | 2 +- compensation/views/compensation_views.py | 1 + compensation/views/eco_account_views.py | 1 + intervention/models.py | 25 +++++++++- .../detail/includes/controls.html | 2 +- intervention/views.py | 3 +- konova/settings.py | 7 ++- locale/de/LC_MESSAGES/django.mo | Bin 17020 -> 17022 bytes locale/de/LC_MESSAGES/django.po | 4 +- 11 files changed, 84 insertions(+), 8 deletions(-) diff --git a/compensation/models.py b/compensation/models.py index 8c45bcf..8e0dde3 100644 --- a/compensation/models.py +++ b/compensation/models.py @@ -15,6 +15,7 @@ from django.utils.translation import gettext_lazy as _ from compensation.settings import COMPENSATION_IDENTIFIER_LENGTH, COMPENSATION_IDENTIFIER_TEMPLATE from intervention.models import Intervention, ResponsibilityData from konova.models import BaseObject, BaseResource, Geometry, UuidModel +from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE from konova.utils.generators import generate_random_string from user.models import UserActionLogEntry @@ -169,6 +170,28 @@ class Compensation(AbstractCompensation): self.identifier = new_id super().save(*args, **kwargs) + def get_LANIS_link(self) -> str: + """ Generates a link for LANIS depending on the geometry + + Returns: + + """ + try: + geom = self.geometry.geom.transform(DEFAULT_SRID_RLP, clone=True) + x = geom.centroid.x + y = geom.centroid.y + zoom_lvl = 16 + except AttributeError: + # If no geometry has been added, yet. + x = 1 + y = 1 + zoom_lvl = 6 + return LANIS_LINK_TEMPLATE.format( + zoom_lvl, + x, + y, + ) + class EcoAccount(AbstractCompensation): """ @@ -203,6 +226,28 @@ class EcoAccount(AbstractCompensation): """ return self.withdraws.all().aggregate(Sum("surface"))["surface__sum"] + def get_LANIS_link(self) -> str: + """ Generates a link for LANIS depending on the geometry + + Returns: + + """ + try: + geom = self.geometry.geom.transform(DEFAULT_SRID_RLP, clone=True) + x = geom.centroid.x + y = geom.centroid.y + zoom_lvl = 16 + except AttributeError: + # If no geometry has been added, yet. + x = 1 + y = 1 + zoom_lvl = 6 + return LANIS_LINK_TEMPLATE.format( + zoom_lvl, + x, + y, + ) + class EcoAccountWithdraw(BaseResource): """ diff --git a/compensation/templates/compensation/detail/compensation/includes/controls.html b/compensation/templates/compensation/detail/compensation/includes/controls.html index 34a5c03..0f5149a 100644 --- a/compensation/templates/compensation/detail/compensation/includes/controls.html +++ b/compensation/templates/compensation/detail/compensation/includes/controls.html @@ -1,7 +1,7 @@ {% load i18n l10n fontawesome_5 %}
- + diff --git a/compensation/templates/compensation/detail/eco_account/includes/controls.html b/compensation/templates/compensation/detail/eco_account/includes/controls.html index c66ba97..9b65a19 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/controls.html +++ b/compensation/templates/compensation/detail/eco_account/includes/controls.html @@ -1,7 +1,7 @@ {% load i18n l10n fontawesome_5 %}
- + diff --git a/compensation/views/compensation_views.py b/compensation/views/compensation_views.py index 900827b..a24d145 100644 --- a/compensation/views/compensation_views.py +++ b/compensation/views/compensation_views.py @@ -95,6 +95,7 @@ def open_view(request: HttpRequest, id: str): "is_default_member": in_group(_user, DEFAULT_GROUP), "is_zb_member": in_group(_user, ZB_GROUP), "is_ets_member": in_group(_user, ETS_GROUP), + "LANIS_LINK": comp.get_LANIS_link(), } context = BaseContext(request, context).context return render(request, template, context) diff --git a/compensation/views/eco_account_views.py b/compensation/views/eco_account_views.py index 9dfdbd8..650a1f7 100644 --- a/compensation/views/eco_account_views.py +++ b/compensation/views/eco_account_views.py @@ -111,6 +111,7 @@ def open_view(request: HttpRequest, id: str): "is_default_member": in_group(_user, DEFAULT_GROUP), "is_zb_member": in_group(_user, ZB_GROUP), "is_ets_member": in_group(_user, ETS_GROUP), + "LANIS_LINK": acc.get_LANIS_link(), } context = BaseContext(request, context).context return render(request, template, context) diff --git a/intervention/models.py b/intervention/models.py index bdafbb4..f5867b2 100644 --- a/intervention/models.py +++ b/intervention/models.py @@ -14,6 +14,7 @@ from django.utils.timezone import now from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE from konova.models import BaseObject, Geometry, UuidModel, BaseResource +from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE from konova.utils import generators from konova.utils.generators import generate_random_string from organisation.models import Organisation @@ -225,4 +226,26 @@ class Intervention(BaseObject): ret_msgs["legal"] = missing_str ret_result = len(ret_msgs) == 0 - return ret_result, ret_msgs \ No newline at end of file + return ret_result, ret_msgs + + def get_LANIS_link(self) -> str: + """ Generates a link for LANIS depending on the geometry + + Returns: + + """ + try: + geom = self.geometry.geom.transform(DEFAULT_SRID_RLP, clone=True) + x = geom.centroid.x + y = geom.centroid.y + zoom_lvl = 16 + except AttributeError: + # If no geometry has been added, yet. + x = 1 + y = 1 + zoom_lvl = 6 + return LANIS_LINK_TEMPLATE.format( + zoom_lvl, + x, + y, + ) \ No newline at end of file diff --git a/intervention/templates/intervention/detail/includes/controls.html b/intervention/templates/intervention/detail/includes/controls.html index b851444..ef263d9 100644 --- a/intervention/templates/intervention/detail/includes/controls.html +++ b/intervention/templates/intervention/detail/includes/controls.html @@ -1,7 +1,7 @@ {% load i18n l10n fontawesome_5 %}
- + diff --git a/intervention/views.py b/intervention/views.py index 0f8f8c8..432fea5 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -11,7 +11,7 @@ from intervention.tables import InterventionTable from konova.contexts import BaseContext from konova.decorators import * from konova.forms import SimpleGeomForm, NewDocumentForm, RemoveModalForm -from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_FORMAT +from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT from konova.utils.message_templates import FORM_INVALID from konova.utils.user_checks import in_group @@ -139,6 +139,7 @@ def open_view(request: HttpRequest, id: str): "is_default_member": in_group(_user, DEFAULT_GROUP), "is_zb_member": in_group(_user, ZB_GROUP), "is_ets_member": in_group(_user, ETS_GROUP), + "LANIS_LINK": intervention.get_LANIS_link() } if not is_data_shared: diff --git a/konova/settings.py b/konova/settings.py index 6f448f0..d2b14fa 100644 --- a/konova/settings.py +++ b/konova/settings.py @@ -48,6 +48,7 @@ DEFAULT_LAT = 50.00 DEFAULT_LON = 7.00 DEFAULT_ZOOM = 8.0 DEFAULT_SRID = 4326 +DEFAULT_SRID_RLP = 25832 # GROUPS DEFAULT_GROUP = "Default" @@ -56,4 +57,8 @@ ETS_GROUP = "Conservation office" # HELP PAGE LINK -HELP_LINK = "https://dienste.naturschutz.rlp.de/doku/doku.php?id=ksp:start" \ No newline at end of file +HELP_LINK = "https://dienste.naturschutz.rlp.de/doku/doku.php?id=ksp:start" + +# Needed to redirect to LANIS +## Values to be inserted are [zoom_level, x_coord, y_coord] +LANIS_LINK_TEMPLATE = "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/index.php?lang=de&zl={}&x={}&y={}&bl=tk_rlp_tms_grau&bo=1&lo=0.8,0.8,0.8,0.6,0.8,0.8,0.8,0.8,0.8&layers=eiv_f,eiv_l,eiv_p,kom_f,kom_l,kom_p,oek_f,ema_f,mae&service=kartendienste_naturschutz" diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index cc0dc4d6c9f7c7f6ac0edd03d53e60cb201b6a98..f36a1fcfce8f1207d5aef602e54f8324f41a5746 100644 GIT binary patch delta 1111 zcmXZbPi#z46vy#X9h5#*ol|Bo%m1tSB8i+WfxR7xRF2aQ=dyo(u} zMkP|03(OV}By(mSrmzb0I3KrTJ?_FKco>z)AgWWBa2{Smb>apt#rvp2#!(4RI^Ux@ zS;jbi3kXz+mk$?opdJ+Q9S)!p+SD1gu*A2?Ax9LEUu$mt!xg@&FV`Rw2C@ z5m6BIWEG^~p~YN8@E`?IQKSbihF*j!2p)P+5GDBiv2*&oncbOr@6B$b68Tq&%~Zr2H!kBE=1<}lJc}Fg8piPsZo=t) z3#?4=f{Cpd88F*`+nocLW_%Ra;|0{llehybr~;m07C)m3Y08`R;y%pbI3C9P*oTX# zMB;_OteK#*VCG>DuEspB!Vzr2BbdO`s6-}Eow|-qIECuOEllD=R3USygy)@~P@Sw} z2mS~MR7q@qxFCmmP{NNmj!LL+Fl^zV^8_Ab{v4{6Pf#1bL?!ypSw|)G(~YCWaK9w# zy`Y^y8D>#;UBt~ejH-MLRmnwEr*5DsuA(-+iz%Ezbzt7jFQ5+ij%xKE%wcRO>|hZO zaK0TU(84OJ(g&!kc#NuS7TfU+Zo?(ihRv*2f+^IxUR0ua)cRxCily}U*T1F-K*Xa$1olT?m>qK?1 z8@+%aOQ7Fr2=zi4xpo`HHmss5oxwD|LLcj>$`d1Dr&6d6IJRKn+x>$lseZ|yzm xs+ZB%!M_M}fE@}mOQNo%4ZCnRcHk(g(uvwwywnvvbLG;#X@94zeej=q{{hNQd5-`9 diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index f61eefb..0ff3303 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -455,7 +455,7 @@ msgstr "Neuen Zielzustand hinzufügen" #: compensation/templates/compensation/detail/compensation/includes/states-after.html:26 #: compensation/templates/compensation/detail/eco_account/includes/states-after.html:26 msgid "Missing surfaces according to states before: " -msgstr "Fehlende Flächenmengen aus Ausgangszustand: " +msgstr "Fehlende Flächenmengen laut Ausgangszustand: " #: compensation/templates/compensation/detail/compensation/includes/states-after.html:33 #: compensation/templates/compensation/detail/compensation/includes/states-before.html:33 @@ -484,7 +484,7 @@ msgstr "Neuen Ausgangszustand hinzufügen" #: compensation/templates/compensation/detail/compensation/includes/states-before.html:26 #: compensation/templates/compensation/detail/eco_account/includes/states-before.html:26 msgid "Missing surfaces according to states after: " -msgstr "Fehlende Flächenmengen aus Zielzustand: " +msgstr "Fehlende Flächenmengen laut Zielzustand: " #: compensation/templates/compensation/detail/compensation/view.html:28 msgid "compensates intervention"