From 95f6e1cb995130066534f461fae257f516bfe835 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Fri, 22 Mar 2024 23:46:30 +0300 Subject: Only display the "edit" link when a user has edit permissions. Signed-off-by: Munyoki Kilyungi --- gn2/wqflask/templates/dataset.html | 24 ++++++++++++++++++++++++ gn2/wqflask/views.py | 12 ++++++++++++ 2 files changed, 36 insertions(+) (limited to 'gn2/wqflask') 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 %}

Description + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.description|safe }}
{% endif %} @@ -184,11 +186,13 @@ {% if dataset.experimentType %}

Experiment Type + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.experimentType|safe }}
{% endif %} @@ -196,11 +200,13 @@ {% if dataset.specifics %}

Specifics of this Dataset + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.specifics }}
{% endif %} @@ -208,11 +214,13 @@ {% if dataset.experimentDesignInfo %}

Experiment Design + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.experimentDesignInfo|safe }}
{% endif %} @@ -220,11 +228,13 @@ {% if dataset.caseInfo %}

About the Cases Used to Generate this Dataset: + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.caseInfo|safe }}
{% endif %} @@ -234,11 +244,13 @@ About the Tissue {%if dataset.tissue and dataset.tissue.label %}({{ dataset.tissue.label }}) {% endif %}Used to Generate this Dataset + {% if dataset.editable %} edit  ] + {% endif %}
{{ dataset.tissueInfo|safe }}
{% endif %} @@ -246,11 +258,13 @@ {% if dataset.platform and dataset.platformInfo %}

About the Array Platform + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.platformInfo|safe }}
{% endif %} @@ -258,11 +272,13 @@ {% if dataset.processingInfo %}

About Data Values and Data Processing + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.processingInfo|safe }}
{% endif %} @@ -270,23 +286,27 @@ {% if dataset.notes %}

Notes + {% if dataset.editable %} edit  ]

+ {% endif %}
{{ dataset.notes|safe }}
{% endif %} {% if dataset.citation|trim %}

Citation + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.citation|safe}}
{% endif %} @@ -294,11 +314,13 @@ {% if dataset.acknowledgement|trim %}

Acknowledgment + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.acknowledgement|safe}}
{% endif %} @@ -306,11 +328,13 @@ {% if dataset.contributors %}

Contributors + {% if dataset.editable %} edit  ] + {% endif %}

{{ dataset.contributors|safe }}
{% 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/", 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, -- cgit v1.2.3