aboutsummaryrefslogtreecommitdiff
path: root/gn2
diff options
context:
space:
mode:
authorJohn Nduli2024-09-10 15:38:15 +0300
committerBonfaceKilz2024-09-17 11:40:42 +0300
commit44d3ab8d7070317241f0348edcf57fb4c3b044ca (patch)
tree5a470e55efdf45b2a9560c0ba3c39e5dc143cb1b /gn2
parent6b2ee8f7ac6b90a53480f2b51289221fb59d5bc0 (diff)
downloadgenenetwork2-44d3ab8d7070317241f0348edcf57fb4c3b044ca.tar.gz
feat: hide edit button if user isnt logged in
Diffstat (limited to 'gn2')
-rw-r--r--gn2/wqflask/templates/wiki/genewiki.html6
-rw-r--r--gn2/wqflask/views.py16
2 files changed, 11 insertions, 11 deletions
diff --git a/gn2/wqflask/templates/wiki/genewiki.html b/gn2/wqflask/templates/wiki/genewiki.html
index 36aa41c1..f0d6675f 100644
--- a/gn2/wqflask/templates/wiki/genewiki.html
+++ b/gn2/wqflask/templates/wiki/genewiki.html
@@ -11,7 +11,9 @@
<h5>
<strong>GeneNetwork:</strong>
</h5>
+
{% if wiki %}
+
<ol class="list-group">
{% for entry in wiki %}
<li class="list-group-item">
@@ -23,12 +25,16 @@
<sup> <small> <a href = "{{ entry.web_url }}" target = "_blank"> <span class = "glyphicon glyphicon-globe" aria-hidden = "true"></span>web</a></small></sup>
{% endif %}
</div>
+
+ {% if is_logged_in %}
<div class="col-sm-2">
<a href="{{ url_for('edit_wiki', comment_id=entry['id']) }}">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</a>
</div>
+ {% endif %}
<sup><small>[<a href="/genewiki/{{ entry.id }}/history" target="_blank">history</a>]</small></sup>
+ </div>
</li>
{% endfor %}
</ol>
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index ec2854c4..5c856b77 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -1301,21 +1301,15 @@ def display_genewiki_page(symbol: str):
"""Fetch GeneRIF metadata from GN3 and display it"""
wiki = {}
try:
- wiki = requests.get(
- urljoin(
- GN3_LOCAL_URL,
- f"/api/metadata/wiki/{symbol}"
- )
- )
+ wiki = requests.get(urljoin(GN3_LOCAL_URL, f"/api/metadata/wiki/{symbol}"))
wiki.raise_for_status()
wiki = wiki.json()
except requests.RequestException as excp:
flash(excp, "alert-warning")
- return render_template(
- "wiki/genewiki.html",
- symbol=symbol,
- wiki=wiki
- )
+ sess_info = session_info()
+ is_logged_in = sess_info.get("user", {}).get("logged_in", False)
+
+ return render_template("wiki/genewiki.html", symbol=symbol, wiki=wiki, is_logged_in=is_logged_in)
@app.route("/genewiki/<int:comment_id>/history")