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:
@@ -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
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user