From 48f76631dfd75a2c2a6ed739854461146b2184bc Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 3 Sep 2024 14:26:36 +0300 Subject: Add comment history page. * gn2/wqflask/templates/wiki/history.html: New page. * gn2/wqflask/views.py (display_wiki_history): New function. Signed-off-by: Munyoki Kilyungi --- gn2/wqflask/templates/wiki/history.html | 139 ++++++++++++++++++++++++++++++++ gn2/wqflask/views.py | 23 ++++++ 2 files changed, 162 insertions(+) create mode 100644 gn2/wqflask/templates/wiki/history.html diff --git a/gn2/wqflask/templates/wiki/history.html b/gn2/wqflask/templates/wiki/history.html new file mode 100644 index 00000000..e10ff683 --- /dev/null +++ b/gn2/wqflask/templates/wiki/history.html @@ -0,0 +1,139 @@ +{% extends "base.html" %} +{% block css %} + +{% endblock %} +{% block content %} + {{ flash_me() }} +
+

GeneWiki Entry History

+ {% if most_recent %} +

+ Most Recent Version: +

+ + + + + + + {% if most_recent["species"] %} + + + + + {% endif %} + {% if most_recent["pubmed_ids"] %} + + + + + {% endif %} + {% if most_recent["web_url"] %} + + + + + {% endif %} + + + + + {% if most_recent["categories"] %} + + + + + {% endif %} + + + + + {% if most_recent["reason"] %} + + + + + {% endif %} + +
Gene Symbol:{{ most_recent["symbol"] }}
Species:{{ most_recent["species"] }}
PubMed IDs: + {% for id in most_recent["pubmed_ids"] %} + {{ id }}  + {% endfor %} +
Web URL:{{ most_recent["web_url"] }}
Entry:{{ most_recent["comment"] }}
Category:{{ '; '.join(most_recent["categories"]) }}
Add Time:{{ most_recent["created"] }}
Reason for Modification:{{ most_recent["reason"] }}
+ {% endif %} +

+ Previous Version: +

+ {% if previous_versions %} + {% for version in previous_versions %} + + + + + + {% if version["species"] %} + + + + + {% endif %} + {% if version["pubmed_ids"] %} + + + + + {% endif %} + {% if version["web_url"] %} + + + + + {% endif %} + + + + + {% if version["categories"] %} + + + + + {% endif %} + + + + + {% if version["reason"] %} + + + + + {% endif %} +
Gene Symbol:{{ version["symbol"] }}
Species:{{ version["species"] }}
PubMed IDs: + {% for id in version["pubmed_ids"] %} + {{ id }}  + {% endfor %} +
Web URL:{{ version["web_url"] }}
Entry:{{ version["comment"] }}
Category:{{ '; '.join(version["categories"]) }}
Add Time:{{ version["created"] }}
Reason for Modification:{{ version["reason"] }}
+ {% endfor %} + {% else %} +

No Previous History

+ {% endif %} +
+{% endblock %} diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index 995b2b31..ce221c36 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -1277,6 +1277,29 @@ def display_genewiki_page(symbol: str): ) +@app.route("/genewiki//history") +def display_wiki_history(comment_id: str): + most_recent = {} + previous_versions = [] + try: + entries = requests.get( + urljoin( + GN3_LOCAL_URL, + f"/api/metadata/wiki/{comment_id}/history" + ) + ) + entries.raise_for_status() + if entries := entries.json(): + most_recent, previous_versions = entries[0], entries[1:] + except requests.RequestException as excp: + flash(excp, "alert-warning") + return render_template( + "wiki/history.html", + most_recent=most_recent, + previous_versions=previous_versions + ) + + @app.route("/datasets/", methods=('GET',)) def get_dataset(name): from gn2.wqflask.oauth2.client import oauth2_get -- cgit v1.2.3