From d6019d7a2af748cd8ee5f86f0e754cb3ef5a2619 Mon Sep 17 00:00:00 2001 From: John Nduli Date: Mon, 26 Aug 2024 20:37:42 +0300 Subject: feat: add template for editting wiki --- gn2/utility/tools.py | 7 +-- gn2/wqflask/templates/wiki/edit_wiki.html | 92 +++++++++++++++++++++++++++++++ gn2/wqflask/views.py | 32 +++++++++++ 3 files changed, 125 insertions(+), 6 deletions(-) create mode 100644 gn2/wqflask/templates/wiki/edit_wiki.html (limited to 'gn2') diff --git a/gn2/utility/tools.py b/gn2/utility/tools.py index d8e21bcd..26ed3a77 100644 --- a/gn2/utility/tools.py +++ b/gn2/utility/tools.py @@ -46,14 +46,11 @@ def get_setting(command_id, guess=None): """ def value(command): if command: - # sys.stderr.write("Found "+command+"\n") app_set(command_id, command) return command - else: - return app.config.get(command_id) + return app.config.get(command_id) # ---- Check whether environment exists - # print("Looking for "+command_id+"\n") command = value(os.environ.get(command_id)) if command is None or command == "": # ---- Check whether setting exists in app @@ -61,10 +58,8 @@ def get_setting(command_id, guess=None): if command is None: command = value(guess) if command is None or command == "": - # print command raise Exception( command_id + ' setting unknown or faulty (update default_settings.py?).') - # print("Set "+command_id+"="+str(command)) return command diff --git a/gn2/wqflask/templates/wiki/edit_wiki.html b/gn2/wqflask/templates/wiki/edit_wiki.html new file mode 100644 index 00000000..942280dc --- /dev/null +++ b/gn2/wqflask/templates/wiki/edit_wiki.html @@ -0,0 +1,92 @@ +{% extends "base.html" %} + +{% block css %} + +{% endblock %} + +{% block content %} + +
+
+
+
+

Edit Wiki

+
+
+ +
+ + +
+
+ + +
+
+ + + (optional, separate by blank space only) +
+
+ + + (optional) +
+
+ + +
+
+ + +
+
+ + + (optional user or project code or your initials) +
+
+ +
+ {% for group in grouped_categories %} +
+ {% for cat in group %} + + {% endfor %} +
+ {% endfor %} +
+
+ + +
+ +
+
+
+ + + + + + + +

+ +

+ +{% endblock %} diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index 4e3c556d..18f749c9 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -1,4 +1,5 @@ """Main routing table for GN2""" + import array import base64 import csv @@ -44,6 +45,7 @@ from flask import flash from gn2.wqflask import search_results from gn2.wqflask import server_side + # Used by YAML in marker_regression from gn2.base.data_set import create_dataset from gn2.base.trait import fetch_symbols @@ -1498,3 +1500,33 @@ def approve_reject_diff() -> Response: return redirect(url_for("view_diff", inbredset_id=inbredset_id, diff_id=form["diff_id"])) + + +@app.route("/wiki//edit") +def edit_wiki(comment_id: int): + """fetch generif metadata from gn3 and display it""" + # FIXME: better error handling + last_wiki_content = ( + monad_requests.get(urljoin(GN3_LOCAL_URL, f"/api/metadata/wiki/{comment_id}")) + .then(lambda res: res) + .either(lambda _: [], lambda x: x.json()) + ) + species_dict = ( + monad_requests.get(urljoin(GN3_LOCAL_URL, "/api/metadata/wiki/species")) + .then(lambda res: res) + .either(lambda _: [], lambda x: x.json()) + ) + categories = ( + monad_requests.get(urljoin(GN3_LOCAL_URL, "/api/metadata/wiki/categories")) + .then(lambda resp: resp) + .either(lambda _: [], lambda x: list(x.json().keys())) + ) + + grouped_categories = [categories[i : i + 3] for i in range(0, len(categories), 3)] + + return render_template( + "wiki/edit_wiki.html", + content=last_wiki_content, + species_dict=species_dict, + grouped_categories=grouped_categories, + ) -- cgit 1.4.1