LANIS Link
* adds LANIS link getter to Intervention, Compensation and EcoAccount for creating a usable link to LANIS * adds/updates translations
This commit is contained in:
parent
07a428d0e5
commit
c165e3f990
@ -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):
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% load i18n l10n fontawesome_5 %}
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<a href="{{LANIS_LINK}}" class="mr-2" target="_blank">
|
||||
<button class="btn btn-default" title="{% trans 'Open in LANIS' %}">
|
||||
LANIS
|
||||
</button>
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% load i18n l10n fontawesome_5 %}
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<a href="{{LANIS_LINK}}" class="mr-2" target="_blank">
|
||||
<button class="btn btn-default" title="{% trans 'Open in LANIS' %}">
|
||||
LANIS
|
||||
</button>
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
@ -226,3 +227,25 @@ class Intervention(BaseObject):
|
||||
|
||||
ret_result = len(ret_msgs) == 0
|
||||
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,
|
||||
)
|
@ -1,7 +1,7 @@
|
||||
{% load i18n l10n fontawesome_5 %}
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<a href="{{LANIS_LINK}}" class="mr-2" target="_blank">
|
||||
<button class="btn btn-default" title="{% trans 'Open in LANIS' %}">
|
||||
LANIS
|
||||
</button>
|
||||
|
@ -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:
|
||||
|
@ -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"
|
||||
@ -57,3 +58,7 @@ ETS_GROUP = "Conservation office"
|
||||
|
||||
# HELP PAGE LINK
|
||||
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"
|
||||
|
Binary file not shown.
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user