From 931867c3a0a3842dd9cad2a204ec79686deaf952 Mon Sep 17 00:00:00 2001 From: Philipp Spitzer Date: Sun, 21 Feb 2021 11:08:32 +0100 Subject: [PATCH] Add links to JSON editing services for sledruns. --- wradmin/template_helper.py | 17 +++++++++++++++++ wradmin/templates/rodelbahn_view.html | 3 +++ 2 files changed, 20 insertions(+) diff --git a/wradmin/template_helper.py b/wradmin/template_helper.py index f7fc01c..b37571f 100644 --- a/wradmin/template_helper.py +++ b/wradmin/template_helper.py @@ -1,3 +1,5 @@ +from urllib.parse import quote_plus + from flask import url_for, current_app import wrpylib.wrvalidators @@ -24,6 +26,21 @@ class PylonsHelper: return 'https://winterrodeln-forum.org/' return 'https://winterrodeln-forum.org/viewforum.php?f={}'.format(forum) + def mediawiki_index_url(self): + return f'{current_app.config["MEDIAWIKI_ROOT"]}/index.php' + + def sledrun_json_schema_url(self, raw: bool = True): + url = f'{self.mediawiki_index_url()}?title=Winterrodeln:Datenschema/Rodelbahn/V1.json' + if raw: + url += '&action=raw' + return url + + def sledrun_json_url(self, page_title, raw: bool = True): + url = f'{self.mediawiki_index_url()}?title={quote_plus(page_title)}/Rodelbahn.json' + if raw: + url += '&action=raw' + return url + def google_maps(self, latitude, longitude): """Builds an URL like http://maps.google.at/maps?q=47.200607,11.260007""" return "https://maps.google.at/maps?q=%.6f,%.6f" % (latitude, longitude) diff --git a/wradmin/templates/rodelbahn_view.html b/wradmin/templates/rodelbahn_view.html index 56f44c6..7559fa6 100644 --- a/wradmin/templates/rodelbahn_view.html +++ b/wradmin/templates/rodelbahn_view.html @@ -89,6 +89,9 @@ {% if sledding.position_latitude and sledding.position_longitude %}
  • Zeige bei Google Maps
  • {% endif %} +
  • Allgemeiner JSON Editor (mit Schema)
  • +
  • JSON der Rodelbahn (falls vorhanden)
  • +
  • JSON Schema für Rodelbahnen
  • {% if sledding.forum_id %}
  • Zeige im Forum
  • {% endif %} -- 2.39.5