diff options
Diffstat (limited to 'gn2/wqflask')
-rw-r--r-- | gn2/wqflask/templates/wiki/edit_wiki.html | 92 | ||||
-rw-r--r-- | gn2/wqflask/views.py | 32 |
2 files changed, 124 insertions, 0 deletions
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 %} +<style> + .panel { + width: 90%; + margin: 2em; + } + .container { + align-content: center; + } +</style> +{% endblock %} + +{% block content %} + +<section class="container center-block"> + <div class="row"> + <div class="col-md-3"></div> + <div class="col-md-9"> + <h2>Edit Wiki</h2> + <br> + <form class="form-horizontal" method="POST"> + <input type="hidden" name="symbol" value="{{ content["symbol"] }}"> + <div class="form-group"> + <label for="reason" class="col-sm-2">Reason for Modification: </label> + <input type="text" name="reason" size=45 maxlength=100> + </div> + <div class="form-group"> + <label for="species" class="col-sm-2">Species: </label> + <select name="species" id="species"> + {% for name, species_name in species_dict.items() %} + <option value="{{ name }}">{{ species_name }}</option> + {% endfor %} + </select> + </div> + <div class="form-group"> + <label for="pubmed_ids" class="col-sm-2">PubMed IDS: </label> + <input type="text" name="pubmed_ids" size=25 maxlength=25> + (optional, separate by blank space only) + </div> + <div class="form-group"> + <label for="weburl" class="col-sm-2">Web resource URL: </label> + <input type="text" name="weburl" value="http://" size=50 maxlength=255> + (optional) + </div> + <div class="form-group"> + <label for="comment" class="col-sm-2">Text: </label> + <textarea name="comment" rows=5 cols=60>{{ content["comment"] }}</textarea> + </div> + <div class="form-group"> + <label for="email" class="col-sm-2">Email: </label> + <input type="text" name="email" value=""> + </div> + <div class="form-group"> + <label for="usercode" class="col-sm-2">User Code: </label> + <input type="text" name="initial" value="{{ content["initial"] }}"/> + (optional user or project code or your initials) + </div> + <div class="form-group"> + <label class="col-sm-2">Category of Gene<br>(Please select one or <br>many categories): </label> + <div class="col-sm-10"> + {% for group in grouped_categories %} + <div class="row"> + {% for cat in group %} + <label class="checkbox-inline col-sm-3"> + <input type="checkbox" name="genecategory" value="{{ cat }} "> {{ cat }} + </label> + {% endfor %} + </div> + {% endfor %} + </div> + <div class="form-group"> + <button type="submit" name="submit" class="btn btn-primary">Update GeneWiki Entry</button> + <button type="reset" name="rest" class="btn btn-secondary">Reset</button> + </div> + </form> + </div> + </div> +<FORM METHOD="POST" ACTION="/webqtl/main.py" NAME="addgenerif"> + +<INPUT TYPE="hidden" NAME="symbol" VALUE="shh"> +<INPUT TYPE="hidden" NAME="curStatus" VALUE="insertCheck"> +<INPUT TYPE="hidden" NAME="FormID" VALUE="geneWiki"> +<INPUT TYPE="hidden" NAME="reason" VALUE=""> +<INPUT TYPE="hidden" NAME="action" VALUE="update"> +<INPUT TYPE="hidden" NAME="Id" VALUE="230"> +<P> + +</FORM> + +{% 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/<int:comment_id>/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, + ) |