Add custom location url from environment variable

Remove trailing dollar in long and lat placeholder
This commit is contained in:
CasperVerswijvelt
2021-04-21 20:13:49 +02:00
committed by R. Miles McCain
parent 14a7ec68f3
commit 3a01fefcff
5 changed files with 22 additions and 2 deletions

View File

@@ -51,7 +51,7 @@
<p>Location</p>
<p class="label">
{% if session.latitude %}
<a href="https://www.google.com/maps/search/?api=1&query={{session.latitude}},{{session.longitude}}">Open
<a href="{{session|location_url}}" target="_blank">Open
in Maps &nearr;</a>
{% else %}
Unknown

View File

@@ -225,3 +225,6 @@ def contextual_url(*args, **kwargs):
urlnode = url_tag(*args, **kwargs)
return ContextualURLNode(urlnode)
@register.filter
def location_url(session):
return settings.LOCATION_URL.replace("$LATITUDE", str(session.latitude)).replace("$LONGITUDE", str(session.longitude))

View File

@@ -340,3 +340,6 @@ BLOCK_ALL_IPS = os.getenv("BLOCK_ALL_IPS", "False") == "True"
# Include date and service ID in salt?
AGGRESSIVE_HASH_SALTING = os.getenv("AGGRESSIVE_HASH_SALTING", "False") == "True"
# What location url should be linked to in the frontend?
LOCATION_URL = os.getenv("LOCATION_URL", "https://www.openstreetmap.org/?mlat=$LATITUDE&mlon=$LONGITUDE")