aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/Plot.py4
-rw-r--r--wqflask/utility/authentication_tools.py10
-rw-r--r--wqflask/utility/redis_tools.py20
-rw-r--r--wqflask/utility/startup_config.py6
4 files changed, 23 insertions, 17 deletions
diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py
index 9b2c6735..d4256a46 100644
--- a/wqflask/utility/Plot.py
+++ b/wqflask/utility/Plot.py
@@ -139,7 +139,7 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab
max_D = max(data)
min_D = min(data)
# add by NL 06-20-2011: fix the error: when max_D is infinite, log function in detScale will go wrong
- if max_D == float('inf') or max_D > webqtlConfig.MAXLRS:
+ if (max_D == float('inf') or max_D > webqtlConfig.MAXLRS) and min_D < webqtlConfig.MAXLRS:
max_D = webqtlConfig.MAXLRS # maximum LRS value
xLow, xTop, stepX = detScale(min_D, max_D)
@@ -156,7 +156,7 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab
j += step
for i, item in enumerate(data):
- if item == float('inf') or item > webqtlConfig.MAXLRS:
+ if (item == float('inf') or item > webqtlConfig.MAXLRS) and min_D < webqtlConfig.MAXLRS:
item = webqtlConfig.MAXLRS # maximum LRS value
j = int((item - xLow) / step)
Count[j] += 1
diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py
index 57dbf8ba..6802d689 100644
--- a/wqflask/utility/authentication_tools.py
+++ b/wqflask/utility/authentication_tools.py
@@ -11,7 +11,6 @@ from utility.redis_tools import (get_redis_conn,
add_resource)
Redis = get_redis_conn()
-
def check_resource_availability(dataset, trait_id=None):
# At least for now assume temporary entered traits are accessible
if type(dataset) == str or dataset.type == "Temp":
@@ -133,12 +132,17 @@ def check_owner_or_admin(dataset=None, trait_id=None, resource_id=None):
else:
resource_id = get_resource_id(dataset, trait_id)
- if g.user_session.user_id in Redis.smembers("super_users"):
+ try:
+ user_id = g.user_session.user_id.encode('utf-8')
+ except:
+ user_id = g.user_session.user_id
+
+ if user_id in Redis.smembers("super_users"):
return "owner"
resource_info = get_resource_info(resource_id)
if resource_info:
- if g.user_session.user_id == resource_info['owner_id']:
+ if user_id == resource_info['owner_id']:
return "owner"
else:
return check_admin(resource_id)
diff --git a/wqflask/utility/redis_tools.py b/wqflask/utility/redis_tools.py
index ff125bd2..de9dde46 100644
--- a/wqflask/utility/redis_tools.py
+++ b/wqflask/utility/redis_tools.py
@@ -127,22 +127,20 @@ def check_verification_code(code):
def get_user_groups(user_id):
- # ZS: Get the groups where a user is an admin or a member and
+ # Get the groups where a user is an admin or a member and
# return lists corresponding to those two sets of groups
- admin_group_ids = [] # ZS: Group IDs where user is an admin
- user_group_ids = [] # ZS: Group IDs where user is a regular user
+ admin_group_ids = [] # Group IDs where user is an admin
+ user_group_ids = [] # Group IDs where user is a regular user
groups_list = Redis.hgetall("groups")
- for key in groups_list:
+ for group_id, group_details in groups_list.items():
try:
- group_ob = json.loads(groups_list[key])
- group_admins = set([this_admin.encode(
- 'utf-8') if this_admin else None for this_admin in group_ob['admins']])
- group_members = set([this_member.encode(
- 'utf-8') if this_member else None for this_member in group_ob['members']])
+ _details = json.loads(group_details)
+ group_admins = set([this_admin if this_admin else None for this_admin in _details['admins']])
+ group_members = set([this_member if this_member else None for this_member in _details['members']])
if user_id in group_admins:
- admin_group_ids.append(group_ob['id'])
+ admin_group_ids.append(group_id)
elif user_id in group_members:
- user_group_ids.append(group_ob['id'])
+ user_group_ids.append(group_id)
else:
continue
except:
diff --git a/wqflask/utility/startup_config.py b/wqflask/utility/startup_config.py
index 56d0af6f..778fb64d 100644
--- a/wqflask/utility/startup_config.py
+++ b/wqflask/utility/startup_config.py
@@ -20,8 +20,12 @@ def app_config():
import os
app.config['SECRET_KEY'] = str(os.urandom(24))
mode = WEBSERVER_MODE
- if mode == "DEV" or mode == "DEBUG":
+ if mode in ["DEV", "DEBUG"]:
app.config['TEMPLATES_AUTO_RELOAD'] = True
+ if mode == "DEBUG":
+ from flask_debugtoolbar import DebugToolbarExtension
+ app.debug = True
+ toolbar = DebugToolbarExtension(app)
print("==========================================")