From fdf14becd8913d0e53cfad45bc4045a77e718769 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Wed, 4 Sep 2024 13:59:16 +0300 Subject: Remove duplicate sections in wiki history page. * gn2/wqflask/templates/wiki/history.html: Use a for loop to remove duplicate section. * gn2/wqflask/views.py (display_wiki_history): Pass all the entries directly into the template. Signed-off-by: Munyoki Kilyungi --- gn2/wqflask/templates/wiki/history.html | 124 +++++++++++--------------------- gn2/wqflask/views.py | 9 +-- 2 files changed, 46 insertions(+), 87 deletions(-) diff --git a/gn2/wqflask/templates/wiki/history.html b/gn2/wqflask/templates/wiki/history.html index 32c52b55..bda802d3 100644 --- a/gn2/wqflask/templates/wiki/history.html +++ b/gn2/wqflask/templates/wiki/history.html @@ -5,88 +5,50 @@

GeneWiki Entry History

-

- Most Recent Version: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Gene Symbol:{{ most_recent.symbol }}
PubMed IDs: - {% for id in most_recent.pubmed_ids %} - {{ id }}  - {% endfor %} - {% if not most_recent.pubmed_ids %}Not Available{% endif %} -
Web URL:{{ most_recent.web_url or "Not Available" }}
Entry:{{ most_recent.comment }}
Category:{{ '; '.join(most_recent.categories) or "Not Available" }}
Add Time:{{ most_recent.created }}
Reason for Modification:{{ most_recent.reason or "Not Available" }}
-

- Previous Version: -

- {% for version in previous_versions %} + {% for entry in entries %} +

+ {% if loop.index0 == 0 %} + Most Recent Version: + {% elif loop.index0 == 1 %} + Previous Version: + {% endif %} +

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Gene Symbol:{{ version.symbol }}
Species:{{ version.species or "Not Available" }}
PubMed IDs: - {% for id in version.pubmed_ids %} - {{ id }}  - {% endfor %} - {% if not most_recent.pubmed_ids %}Not Available{% endif %} -
Web URL:{{ version.web_url or "Not Available " }}
Entry:{{ version.comment }}
Category:{{ '; '.join(version.categories) or "Not Available" }}
Add Time:{{ version.created }}
Reason for Modification:{{ version.reason or "Not Available" }}
Gene Symbol:{{ entry.symbol }}
PubMed IDs: + {% for id in entry.pubmed_ids %} + {{ id }}  + {% endfor %} + {% if not entry.pubmed_ids %}Not Available{% endif %} +
Web URL:{{ entry.web_url or "Not Available" }}
Entry:{{ entry.comment }}
Category:{{ '; '.join(entry.categories) or "Not Available" }}
Add Time:{{ entry.created }}
Reason for Modification:{{ entry.reason or "Not Available" }}
{% endfor %}
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index ce221c36..7e8cd901 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -1279,8 +1279,7 @@ def display_genewiki_page(symbol: str): @app.route("/genewiki//history") def display_wiki_history(comment_id: str): - most_recent = {} - previous_versions = [] + entries = [] try: entries = requests.get( urljoin( @@ -1289,14 +1288,12 @@ def display_wiki_history(comment_id: str): ) ) entries.raise_for_status() - if entries := entries.json(): - most_recent, previous_versions = entries[0], entries[1:] + entries = entries.json() except requests.RequestException as excp: flash(excp, "alert-warning") return render_template( "wiki/history.html", - most_recent=most_recent, - previous_versions=previous_versions + entries=entries ) -- cgit v1.2.3