From e7f884ab69919818948a7d6ef2b6882eba8d815b Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 19 May 2023 10:49:36 +0300 Subject: auth: Use auth privileges to control UI display Use the privileges from the authorisation endpoint to control which elements of the UI are displayed to the user. * wqflask/base/trait.py: Remove unused import * wqflask/wqflask/show_trait/show_trait.py: Unhook from GN-PROXY * wqflask/wqflask/templates/show_trait.html: Display or hide UI elements depending on the privileges the user has. * wqflask/wqflask/templates/show_trait_details.html: Display or hide UI elements depending on the privileges the user has. * wqflask/wqflask/views.py: Pass privileges, user, and resource details on to the UI template to be used for controlling UI element display. --- wqflask/base/trait.py | 2 +- wqflask/wqflask/show_trait/show_trait.py | 5 - wqflask/wqflask/templates/show_trait.html | 224 +++++++++++----------- wqflask/wqflask/templates/show_trait_details.html | 6 +- wqflask/wqflask/views.py | 33 ++-- 5 files changed, 134 insertions(+), 136 deletions(-) diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index e6e1c6b3..37085448 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -7,7 +7,7 @@ from base import webqtlConfig from base.webqtlCaseData import webqtlCaseData from base.data_set import create_dataset from utility.authentication_tools import check_resource_availability -from utility.tools import GN2_BASE_URL, GN_PROXY_URL +from utility.tools import GN2_BASE_URL from utility.redis_tools import get_redis_conn, get_resource_id from flask import g, request, url_for diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index e958e78c..13e11ff2 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -37,17 +37,12 @@ ONE_YEAR = 60 * 60 * 24 * 365 class ShowTrait: def __init__(self, db_cursor, user_id, kw): - self.admin_status = None if 'trait_id' in kw and kw['dataset'] != "Temp": self.temp_trait = False self.trait_id = kw['trait_id'] helper_functions.get_species_dataset_trait(self, kw) self.resource_id = get_resource_id(self.dataset, self.trait_id) - self.admin_status = get_highest_user_access_role( - user_id=user_id, - resource_id=(self.resource_id or ""), - gn_proxy_url=GN_PROXY_URL) elif 'group' in kw: self.temp_trait = True self.trait_id = "Temp_" + kw['species'] + "_" + kw['group'] + \ diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index b0390ace..bc5d75cd 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -1,33 +1,38 @@ {% extends "base.html" %} +{%from "oauth2/display_error.html" import display_error%} + {% block title %}Trait Data and Analysis{% endblock %} + {% block css %} - - - - - - - - - - + + + + + + + + + + {% endblock %} + {% block content %} + {{flash_me()}} + {%if "group:resource:view-resource" in trait_privileges%}