aboutsummaryrefslogtreecommitdiff
path: root/gn2
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-03-22 23:46:30 +0300
committerBonfaceKilz2024-03-26 10:01:13 +0300
commit95f6e1cb995130066534f461fae257f516bfe835 (patch)
tree38b9829d1f28d877438a1c7482975cd42f5afdbe /gn2
parentae3c0f265e109585d91166a6b08a145e59270a14 (diff)
downloadgenenetwork2-95f6e1cb995130066534f461fae257f516bfe835.tar.gz
Only display the "edit" link when a user has edit permissions.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn2')
-rw-r--r--gn2/wqflask/templates/dataset.html24
-rw-r--r--gn2/wqflask/views.py12
2 files changed, 36 insertions, 0 deletions
diff --git a/gn2/wqflask/templates/dataset.html b/gn2/wqflask/templates/dataset.html
index 0863aca5..570401c9 100644
--- a/gn2/wqflask/templates/dataset.html
+++ b/gn2/wqflask/templates/dataset.html
@@ -172,11 +172,13 @@
{% if dataset.description %}
<h3>
<strong>Description</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=description&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.description|safe }}</div>
{% endif %}
@@ -184,11 +186,13 @@
{% if dataset.experimentType %}
<h3>
<strong>Experiment Type</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=experimentType&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.experimentType|safe }}</div>
{% endif %}
@@ -196,11 +200,13 @@
{% if dataset.specifics %}
<h3>
<strong>Specifics of this Dataset</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=specifics&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.specifics }}</div>
{% endif %}
@@ -208,11 +214,13 @@
{% if dataset.experimentDesignInfo %}
<h3>
<strong>Experiment Design</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=experimentDesignInfo&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.experimentDesignInfo|safe }}</div>
{% endif %}
@@ -220,11 +228,13 @@
{% if dataset.caseInfo %}
<h3>
<strong>About the Cases Used to Generate this Dataset:</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=caseInfo&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.caseInfo|safe }}</div>
{% endif %}
@@ -234,11 +244,13 @@
<strong>About the Tissue
{%if dataset.tissue and dataset.tissue.label %}({{ dataset.tissue.label }})
{% endif %}Used to Generate this Dataset</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=tissueInfo&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.tissueInfo|safe }}</div>
{% endif %}
@@ -246,11 +258,13 @@
{% if dataset.platform and dataset.platformInfo %}
<h3 title="{{ dataset.platform.label }}">
<strong>About the Array Platform</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=platformInfo&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.platformInfo|safe }}</div>
{% endif %}
@@ -258,11 +272,13 @@
{% if dataset.processingInfo %}
<h3>
<strong>About Data Values and Data Processing</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=processingInfo&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.processingInfo|safe }}</div>
{% endif %}
@@ -270,23 +286,27 @@
{% if dataset.notes %}
<h3>
<strong>Notes</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=notes&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
</h3>
+ {% endif %}
<div>{{ dataset.notes|safe }}</div>
{% endif %}
{% if dataset.citation|trim %}
<h3>
<strong>Citation</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=citation&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.citation|safe}}</div>
{% endif %}
@@ -294,11 +314,13 @@
{% if dataset.acknowledgement|trim %}
<h3>
<strong>Acknowledgment</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=acknowledgement&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.acknowledgement|safe}}</div>
{% endif %}
@@ -306,11 +328,13 @@
{% if dataset.contributors %}
<h3>
<strong>Contributors</strong>
+ {% if dataset.editable %}
<sup>
[&nbsp;
<a href="/metadata/edit?type=dcat:Dataset&section=contributors&name={{ dataset.label}}" target="_blank">edit</a>
&nbsp;]
</sup>
+ {% endif %}
</h3>
<div>{{ dataset.contributors|safe }}</div>
{% endif %}
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index 81cacecf..25c4ee1b 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -1150,11 +1150,23 @@ def display_generif_page(symbol):
@app.route("/datasets/<name>", methods=('GET',))
def get_dataset(name):
+ from gn2.wqflask.oauth2.client import oauth2_get
+ from gn2.wqflask.oauth2.client import user_logged_in
+ from gn2.wqflask.oauth2.request_utils import user_details
+ from gn2.wqflask.oauth2.request_utils import process_error
+
+ result = oauth2_get(
+ f"auth/resource/authorisation/{name}"
+ ).either(
+ lambda err: {"roles": []},
+ lambda val: val
+ )
metadata = requests.get(
urljoin(
GN3_LOCAL_URL,
f"/api/metadata/datasets/{name}")
).json()
+ metadata["editable"] = "group:resource:edit-resource" in result["roles"]
return render_template(
"dataset.html",
name=name,