diff options
author | zsloan | 2020-06-24 17:13:45 -0500 |
---|---|---|
committer | zsloan | 2020-06-24 17:13:45 -0500 |
commit | 645c07b98aae9508e8a0aeedd8eaca815d5daf54 (patch) | |
tree | dfb545105f95bd35fe87c549049d3833281aa6bb /wqflask/utility | |
parent | 9b1aecdbb51c7cb843ca79ab430d8dc2b9d3767e (diff) | |
download | genenetwork2-645c07b98aae9508e8a0aeedd8eaca815d5daf54.tar.gz |
Temporary partial fix to issue of resources without info; need to add something that automatically inserts resources with default privileges
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/authentication_tools.py | 11 | ||||
-rw-r--r-- | wqflask/utility/redis_tools.py | 5 |
2 files changed, 11 insertions, 5 deletions
diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py index 06b2854a..f9028f32 100644 --- a/wqflask/utility/authentication_tools.py +++ b/wqflask/utility/authentication_tools.py @@ -32,6 +32,8 @@ def check_resource_availability(dataset, trait_id=None): if resource_id: resource_info = get_resource_info(resource_id) + if not resource_info: + return webqtlConfig.DEFAULT_PRIVILEGES else: return response #ZS: Need to substitute in something that creates the resource in Redis later @@ -85,9 +87,10 @@ def check_owner_or_admin(dataset=None, trait_id=None, resource_id=None): return "owner" resource_info = get_resource_info(resource_id) - if g.user_session.user_id == resource_info['owner_id']: - return "owner" - else: - return check_admin(resource_id) + if resource_info: + if g.user_session.user_id == resource_info['owner_id']: + return "owner" + else: + return check_admin(resource_id) return "not-admin"
\ No newline at end of file diff --git a/wqflask/utility/redis_tools.py b/wqflask/utility/redis_tools.py index 9d09a66b..8a5f95ee 100644 --- a/wqflask/utility/redis_tools.py +++ b/wqflask/utility/redis_tools.py @@ -280,7 +280,10 @@ def get_resource_id(dataset, trait_id=None): def get_resource_info(resource_id): resource_info = Redis.hget("resources", resource_id) - return json.loads(resource_info) + if resource_info: + return json.loads(resource_info) + else: + return None def add_resource(resource_info): if 'trait' in resource_info['data']: |