diff options
-rwxr-xr-x | wqflask/base/data_set.py | 50 | ||||
-rw-r--r-- | wqflask/wqflask/correlation/show_corr_results.py | 8 | ||||
-rw-r--r-- | wqflask/wqflask/templates/admin/group_manager.html | 49 | ||||
-rw-r--r-- | wqflask/wqflask/user_manager.py | 16 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 13 |
5 files changed, 106 insertions, 30 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 803cbc4f..03b24230 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -77,14 +77,31 @@ def create_dataset(dataset_name, dataset_type = None): def create_datasets_list(): key = "all_datasets" result = Redis.get(key) + if result: print("Cache hit!!!") - result = pickle.loads(result) + datasets = pickle.loads(result) + else: + datasets = list() with Bench("Creating DataSets object"): - ds = DataSets() - Redis.set(key, pickle.dumps(result)) - Redis.expire(key, 2*60) + type_dict = {'Publish': 'PublishFreeze', + 'ProbeSet': 'ProbeSetFreeze', + 'Geno': 'GenoFreeze'} + + for dataset_type in type_dict: + query = "SELECT Name FROM {}".format(type_dict[dataset_type]) + for result in g.db.execute(query).fetchall(): + #The query at the beginning of this function isn't necessary here, but still would + #rather just reuse it + print("type: {}\tname: {}".format(dataset_type, result.Name)) + dataset = create_dataset(result.Name, dataset_type) + datasets.append(dataset) + + Redis.set(key, pickle.dumps(datasets, pickle.HIGHEST_PROTOCOL)) + Redis.expire(key, 60*60) + + return datasets def create_in_clause(items): @@ -240,24 +257,13 @@ class DatasetGroup(object): self.samplelist = list(genotype.prgy) -class DataSets(object): - """Builds a list of DataSets""" - - def __init__(self): - self.datasets = list() - - type_dict = {'Publish': 'PublishFreeze', - 'ProbeSet': 'ProbeSetFreeze', - 'Geno': 'GenoFreeze'} - - for dataset_type in type_dict: - query = "SELECT Name FROM {}".format(type_dict[dataset_type]) - for result in g.db.execute(query).fetchall(): - #The query at the beginning of this function isn't necessary here, but still would - #rather just reuse it - print("type: {}\tname: {}".format(dataset_type, result.Name)) - create_dataset(result.Name, dataset_type) - +#class DataSets(object): +# """Builds a list of DataSets""" +# +# def __init__(self): +# self.datasets = list() +# + #query = """SELECT Name FROM ProbeSetFreeze # UNION diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 3b47e970..f69fe551 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -205,10 +205,10 @@ class CorrelationResults(object): - trait_list = self.getTissueCorrelationByList( primary_trait_symbol = self.this_trait.symbol, - corr_results = self.correlation_results, - TissueProbeSetFreezeId = 1, - method=1) + #trait_list = self.getTissueCorrelationByList( primary_trait_symbol = self.this_trait.symbol, + # corr_results = self.correlation_results, + # TissueProbeSetFreezeId = 1, + # method=1) #XZ, 09/18/2008: get all information about the user selected database. #target_db_name = fd.corr_dataset diff --git a/wqflask/wqflask/templates/admin/group_manager.html b/wqflask/wqflask/templates/admin/group_manager.html new file mode 100644 index 00000000..6b7809d3 --- /dev/null +++ b/wqflask/wqflask/templates/admin/group_manager.html @@ -0,0 +1,49 @@ +{% extends "base.html" %} +{% block title %}Group Manager{% endblock %} +{% block content %} +<!-- Start of body --> + <header class="jumbotron subhead" id="overview"> + <div class="container"> + <h1>Group Manager</h1> + </div> + </header> + + <div class="container"> + <div class="page-header"> + + </div> + <form> + <div class="control-group"> + <b>Group Name: </b> + <div class="input-append"> + <input type="text" name="group_name"> + <button type="submit" class="btn btn-primary">Save</button> + </div> + </div> + + <table class="table table-hover"> + <thead> + <tr> + <th>Read</th> + <th>Type</th> + <th>ID</th> + <th>Name</th> + <th>Full Name</th> + </tr> + </thead> + {% for dataset in datasets %} + <tr> + <td><input type="checkbox" name="read" value="{{ dataset.type }}:{{ dataset.name }}"></td> + <td>{{ dataset.type }}</td> + <td>{{ dataset.id }}</td> + <td>{{ dataset.name }}</td> + <td>{{ dataset.fullname }}</td> + </tr> + {% endfor %} + </table> + </form> + </div> + +<!-- End of body --> + +{% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index b8ebc71f..9e666bbd 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -13,6 +13,8 @@ from flask import Flask, g from pprint import pformat as pf +from base.data_set import create_datasets_list + #from app import db print("globals are:", globals()) @@ -32,6 +34,20 @@ class UserManager(object): #print("user is:", user) self.user = model.User.query.get(self.user_id) print("user is:", self.user) + datasets = create_datasets_list() + for dataset in datasets: + if not dataset.check_confidentiality(): + continue + print("\n Name:", dataset.name) + print(" Type:", dataset.type) + print(" ID:", dataset.id) + print(" Confidential:", dataset.check_confidentiality()) + #print(" ---> self.datasets:", self.datasets) + + +class GroupsManager(object): + def __init__(self, kw): + self.datasets = create_datasets_list() class RolesManager(object): diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index bd56f7a9..813075b8 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -54,7 +54,7 @@ def connect_db(): @app.route("/") def index_page(): print("Sending index_page") - create_datasets_list() + #create_datasets_list() #key = "all_datasets" #result = Redis.get(key) #if result: @@ -63,7 +63,7 @@ def index_page(): #else: # with Bench("Creating DataSets object"): # ds = DataSets() - # Redis.set(key, pickle.dumps(result)) + # Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL)) # Redis.expire(key, 2*60) #print("[orange] ds:", ds.datasets) return render_template("index_page.html") @@ -112,7 +112,7 @@ def search_page(): result = the_search.__dict__ print("result: ", pf(result)) - Redis.set(key, pickle.dumps(result)) + Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL)) Redis.expire(key, 60*60) if result['quick']: @@ -232,7 +232,7 @@ def marker_regression_page(): # print(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item)) #causeerror - Redis.set(key, pickle.dumps(result)) + Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL)) Redis.expire(key, 60*60) with Bench("Rendering template"): @@ -283,6 +283,11 @@ def manage_user(): template_vars = user_manager.UserManager(request.args) return render_template("admin/ind_user_manager.html", **template_vars.__dict__) +@app.route("/manage/groups") +def manage_groups(): + template_vars = user_manager.GroupsManager(request.args) + return render_template("admin/group_manager.html", **template_vars.__dict__) + def json_default_handler(obj): '''Based on http://stackoverflow.com/a/2680060/1175849''' |