From 9f9969d09d9b027e93183d2df7de312772954b39 Mon Sep 17 00:00:00 2001 From: Philipp Spitzer Date: Sat, 20 Feb 2021 16:50:03 +0100 Subject: [PATCH] Allow to JSON-edit a sledrun. --- wradmin/__init__.py | 7 + wradmin/controllers/rodelbahn.py | 13 ++ wradmin/templates/json_editor.html | 262 +++++++++++++++++++++++++++++ 3 files changed, 282 insertions(+) create mode 100644 wradmin/templates/json_editor.html diff --git a/wradmin/__init__.py b/wradmin/__init__.py index b2c530d..7284a17 100644 --- a/wradmin/__init__.py +++ b/wradmin/__init__.py @@ -38,6 +38,13 @@ def rodelbahn_view(id): return RodelbahnController().view(id) +@app.route("/rodelbahn/json/edit/") +@login_required +@admin_permission.require(403) +def rodelbahn_json_edit(id): + return RodelbahnController().json_edit(id) + + @app.route("/rodelbahn/update") @login_required def rodelbahn_update(): diff --git a/wradmin/controllers/rodelbahn.py b/wradmin/controllers/rodelbahn.py index 2089cdd..345cbc1 100644 --- a/wradmin/controllers/rodelbahn.py +++ b/wradmin/controllers/rodelbahn.py @@ -8,6 +8,7 @@ import wrpylib.mwmarkup from wradmin.app import db from wradmin.model import WrSledrunCache, WrReport +from wradmin.template_helper import PylonsHelper class RodelbahnController: @@ -34,6 +35,18 @@ class RodelbahnController: items_per_page=25) return render_template('rodelbahn_view.html', sledding=sledrun, paginator=paginator) + def json_edit(self, sledrun_id): + q = db.session.query(WrSledrunCache) + sledrun = q.get(sledrun_id) + if sledrun is None: + abort(404) + h = PylonsHelper() + return render_template('json_editor.html', + schema_url=url_for('static', filename='schema_v1.json'), + #json_url=url_for('static', filename='latschenhuette.json') + json_url=h.wiki(sledrun.page_title) + ) + def update(self): """Updates the wrsledruncache table from the wiki""" c = db.session.connection() diff --git a/wradmin/templates/json_editor.html b/wradmin/templates/json_editor.html new file mode 100644 index 0000000..fb82fb5 --- /dev/null +++ b/wradmin/templates/json_editor.html @@ -0,0 +1,262 @@ +{% extends "master.html" %} +{% block head %} + + {% block title %}JSON Editor{% endblock %} + + + + + +{% endblock %} + +{% block content %} +
+ + + +{% endblock %} -- 2.39.5