diff options
author | Munyoki Kilyungi | 2024-09-03 14:26:36 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-09-05 16:41:17 +0300 |
commit | 48f76631dfd75a2c2a6ed739854461146b2184bc (patch) | |
tree | 507b4c9016f3d7aa16d75f56a009c98f9c66d83a | |
parent | 7c2d18143f608b98be577e41257db8954a0c3c7f (diff) | |
download | genenetwork2-48f76631dfd75a2c2a6ed739854461146b2184bc.tar.gz |
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 <me@bonfacemunyoki.com>
-rw-r--r-- | gn2/wqflask/templates/wiki/history.html | 139 | ||||
-rw-r--r-- | gn2/wqflask/views.py | 23 |
2 files changed, 162 insertions, 0 deletions
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 %} + <style type="text/css"> + h3 { + color: #336699; + } + + table tbody th { + width: 18em; + } + + table tbody th, + table tbody td { + padding: 3px; + } + + table { + margin-left: 0.5em; + } + </style> +{% endblock %} +{% block content %} + {{ flash_me() }} + <div class = "container container-fluid"> + <h2>GeneWiki Entry History</h2> + {% if most_recent %} + <h3> + <strong>Most Recent Version:</strong> + </h3> + <table class="table table-responsive table-bordered"> + <tbody> + <tr> + <th>Gene Symbol:</th> + <td>{{ most_recent["symbol"] }}</td> + </tr> + {% if most_recent["species"] %} + <tr> + <th>Species:</th> + <td>{{ most_recent["species"] }}</td> + </tr> + {% endif %} + {% if most_recent["pubmed_ids"] %} + <tr> + <th>PubMed IDs:</th> + <td> + {% for id in most_recent["pubmed_ids"] %} + <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ id }}&dopt=Abstract">{{ id }}</a> + {% endfor %} + </td> + </tr> + {% endif %} + {% if most_recent["web_url"] %} + <tr> + <th>Web URL:</th> + <td>{{ most_recent["web_url"] }}</td> + </tr> + {% endif %} + <tr> + <th>Entry:</th> + <td>{{ most_recent["comment"] }}</td> + </tr> + {% if most_recent["categories"] %} + <tr> + <th>Category:</th> + <td>{{ '; '.join(most_recent["categories"]) }}</td> + </tr> + {% endif %} + <tr> + <th>Add Time:</th> + <td>{{ most_recent["created"] }}</td> + </tr> + {% if most_recent["reason"] %} + <tr> + <th>Reason for Modification:</th> + <td>{{ most_recent["reason"] }}</td> + </tr> + {% endif %} + </tbody> + </table> + {% endif %} + <h3> + <strong>Previous Version:</strong> + </h3> + {% if previous_versions %} + {% for version in previous_versions %} + <table class="table table-responsive table-bordered"> + <tr> + <th>Gene Symbol:</th> + <td>{{ version["symbol"] }}</td> + </tr> + {% if version["species"] %} + <tr> + <th>Species:</th> + <td>{{ version["species"] }}</td> + </tr> + {% endif %} + {% if version["pubmed_ids"] %} + <tr> + <th>PubMed IDs:</th> + <td> + {% for id in version["pubmed_ids"] %} + <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ id }}&dopt=Abstract">{{ id }}</a> + {% endfor %} + </td> + </tr> + {% endif %} + {% if version["web_url"] %} + <tr> + <th>Web URL:</th> + <td>{{ version["web_url"] }}</td> + </tr> + {% endif %} + <tr> + <th>Entry:</th> + <td>{{ version["comment"] }}</td> + </tr> + {% if version["categories"] %} + <tr> + <th>Category:</th> + <td>{{ '; '.join(version["categories"]) }}</td> + </tr> + {% endif %} + <tr> + <th>Add Time:</th> + <td>{{ version["created"] }}</td> + </tr> + {% if version["reason"] %} + <tr> + <th>Reason for Modification:</th> + <td>{{ version["reason"] }}</td> + </tr> + {% endif %} + </table> + {% endfor %} + {% else %} + <p>No Previous History</p> + {% endif %} + </div> +{% 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/<int:comment_id>/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/<name>", methods=('GET',)) def get_dataset(name): from gn2.wqflask.oauth2.client import oauth2_get |