From 8de4aeed79ec08dab92efa3cd2a6be015c109015 Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Wed, 29 Nov 2017 23:49:33 +0100 Subject: [PATCH] Generate map popups from template. --- ticdesk/static/style.less | 4 ++++ ticdesk_org/templates/ticdesk_org/map_popup_content.html | 4 ++++ ticdesk_org/views.py | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 ticdesk_org/templates/ticdesk_org/map_popup_content.html diff --git a/ticdesk/static/style.less b/ticdesk/static/style.less index 3300def..c4b2add 100644 --- a/ticdesk/static/style.less +++ b/ticdesk/static/style.less @@ -54,3 +54,7 @@ img.person-img { .leaflet-container#map { min-height: 700px; } + +.map-popup-img { + height: 150px; +} diff --git a/ticdesk_org/templates/ticdesk_org/map_popup_content.html b/ticdesk_org/templates/ticdesk_org/map_popup_content.html new file mode 100644 index 0000000..075c98a --- /dev/null +++ b/ticdesk_org/templates/ticdesk_org/map_popup_content.html @@ -0,0 +1,4 @@ +<h3>{{ person.cn }}</h3> +<p> + <img src="{{ person.jpeg_photo__url }}" alt="{{ person.cn }}" class="map-popup-img" /> +</p> diff --git a/ticdesk_org/views.py b/ticdesk_org/views.py index a3426ab..6fb2450 100644 --- a/ticdesk_org/views.py +++ b/ticdesk_org/views.py @@ -1,6 +1,7 @@ from django.apps import apps from django.http import JsonResponse, HttpResponse from django.shortcuts import redirect, render +from django.template.loader import get_template from django.urls import reverse from django_tables2 import RequestConfig @@ -69,10 +70,15 @@ def persons(request, group=None): geojson = [] for person in persons: if person.latitude and person.longitude: + # Generate popup content from template + template = get_template('ticdesk_org/map_popup_content.html') + popup_content = template.render({'person': person}) + + # Add item to pre-GeoJSON structure geojson.append({"type": "Feature", "properties": { "id": person.uid_number, - "popupContent": person.cn + "popupContent": popup_content }, "geometry": { "type": "Point", -- GitLab