diff options
author | Lei Yan | 2013-07-03 20:56:45 +0000 |
---|---|---|
committer | Lei Yan | 2013-07-03 20:56:45 +0000 |
commit | 76ad4e6ae15f4d42ddd420cd14936c149aa0bb31 (patch) | |
tree | 7f82df4895e80788e5b9e9fb07b0d7adb97a0738 | |
parent | d95eff3f0410ec5cddd82398f6db0fffa5d9be0b (diff) | |
parent | 253df1a5adb060df3202de5b80a5065a3614e368 (diff) | |
download | genenetwork2-76ad4e6ae15f4d42ddd420cd14936c149aa0bb31.tar.gz |
Merge /home/zas1024/gene
-rwxr-xr-x | web/genotypes/B6D2F2-PSU.geno | 8 | ||||
-rwxr-xr-x | wqflask/base/data_set.py | 105 | ||||
-rw-r--r-- | wqflask/base/species.py | 10 | ||||
-rw-r--r-- | wqflask/cfg/default_settings.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/correlation/show_corr_results.py | 7 | ||||
-rw-r--r-- | wqflask/wqflask/search_results.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/login.coffee | 6 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/login.js | 5 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/thank_you.coffee | 4 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/thank_you.js | 10 | ||||
-rw-r--r-- | wqflask/wqflask/templates/admin/group_manager.html | 83 | ||||
-rw-r--r-- | wqflask/wqflask/templates/base.html | 6 | ||||
-rw-r--r-- | wqflask/wqflask/templates/security/thank_you.html | 8 | ||||
-rw-r--r-- | wqflask/wqflask/user_manager.py | 16 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 32 |
15 files changed, 260 insertions, 44 deletions
diff --git a/web/genotypes/B6D2F2-PSU.geno b/web/genotypes/B6D2F2-PSU.geno index 2c8876a0..a0c1728f 100755 --- a/web/genotypes/B6D2F2-PSU.geno +++ b/web/genotypes/B6D2F2-PSU.geno @@ -1,5 +1,5 @@ -"#This is B6D2F2-PSU genotype file, it should be tab-delimited"
-"#the first three/four columns should be ""Chr, Locus, cM, [Mb]"" (case sensitive)"
+#This is B6D2F2-PSU genotype file, it should be tab-delimited
+#the first three/four columns should be ""Chr, Locus, cM, [Mb]"" (case sensitive)
#please save as Unix format text file.
#comment line always start with a '#'
#type riset or intercross
@@ -8,9 +8,9 @@ #abbreviation of maternal or paternal parents
@mat:B
@pat:D
-"#heterozygous , optional, default is ""H"""
+#heterozygous , optional, default is ""H""
@het:H
-"#Unknown , optional, default is ""U"""
+#Unknown , optional, default is ""U""
@unk:U
Chr Locus cM Mb PSU0001 PSU0004 PSU0007 PSU0022 PSU0024 PSU0042 PSU0044 PSU0045 PSU0046 PSU0048 PSU0049 PSU0050 PSU0052 PSU0053 PSU0054 PSU0055 PSU0056 PSU0057 PSU0058 PSU0059 PSU0060 PSU0061 PSU0062 PSU0063 PSU0066 PSU0067 PSU0068 PSU0069 PSU0070 PSU0071 PSU0072 PSU0074 PSU0077 PSU0079 PSU0080 PSU0082 PSU0083 PSU0084 PSU0085 PSU0086 PSU0087 PSU0089 PSU0090 PSU0091 PSU0092 PSU0093 PSU0094 PSU0095 PSU0096 PSU0097 PSU0098 PSU0099 PSU0100 PSU0102 PSU0103 PSU0104 PSU0107 PSU0108 PSU0109 PSU0110 PSU0112 PSU0113 PSU0114 PSU0116 PSU0117 PSU0118 PSU0119 PSU0122 PSU0124 PSU0126 PSU0128 PSU0130 PSU0131 PSU0132 PSU0133 PSU0134 PSU0135 PSU0136 PSU0137 PSU0138 PSU0139 PSU0140 PSU0141 PSU0142 PSU0143 PSU0146 PSU0147 PSU0148 PSU0152 PSU0153 PSU0155 PSU0158 PSU0159 PSU0163 PSU0164 PSU0165 PSU0166 PSU0167 PSU0168 PSU0169 PSU0170 PSU0172 PSU0173 PSU0174 PSU0175 PSU0177 PSU0178 PSU0179 PSU0180 PSU0182 PSU0183 PSU0187 PSU0188 PSU0190 PSU0191 PSU0193 PSU0194 PSU0196 PSU0197 PSU0198 PSU0199 PSU0205 PSU0206 PSU0207 PSU0208 PSU0209 PSU0210 PSU0211 PSU0212 PSU0213 PSU0214 PSU0216 PSU0218 PSU0219 PSU0220 PSU0222 PSU0223 PSU0225 PSU0226 PSU0227 PSU0229 PSU0230 PSU0231 PSU0234 PSU0235 PSU0236 PSU0238 PSU0239 PSU0241 PSU0242 PSU0243 PSU0244 PSU0246 PSU0247 PSU0248 PSU0250 PSU0251 PSU0255 PSU0257 PSU0258 PSU0260 PSU0261 PSU0262 PSU0263 PSU0264 PSU0271 PSU0272 PSU0273 PSU0274 PSU0275 PSU0276 PSU0278 PSU0280 PSU0282 PSU0283 PSU0285 PSU0286 PSU0287 PSU0288 PSU0289 PSU0291 PSU0292 PSU0293 PSU0295 PSU0296 PSU0299 PSU0300 PSU0301 PSU0302 PSU0304 PSU0305 PSU0306 PSU0308 PSU0309 PSU0310 PSU0311 PSU0312 PSU0313 PSU0314 PSU0315 PSU0316 PSU0317 PSU0318 PSU0319 PSU0320 PSU0321 PSU0323 PSU0325 PSU0326 PSU0327 PSU0328 PSU0329 PSU0330 PSU0331 PSU0334 PSU0336 PSU0337 PSU0338 PSU0339 PSU0340 PSU0341 PSU0342 PSU0343 PSU0344 PSU0346 PSU0349 PSU0351 PSU0352 PSU0353 PSU0355 PSU0356 PSU0357 PSU0358 PSU0359 PSU0360 PSU0361 PSU0362 PSU0363 PSU0366 PSU0367 PSU0369 PSU0370 PSU0371 PSU0372 PSU0373 PSU0374 PSU0375 PSU0376 PSU0378 PSU0379 PSU0381 PSU0382 PSU0383 PSU0384 PSU0385 PSU0388 PSU0390 PSU0391 PSU0392 PSU0393 PSU0395 PSU0397 PSU0399 PSU0400 PSU0401 PSU0403 PSU0405 PSU0406 PSU0408 PSU0410 PSU0412 PSU0413 PSU0414 PSU0416 PSU0417 PSU0418 PSU0420 PSU0421 PSU0423 PSU0425 PSU0426 PSU0430 PSU0431 PSU0434 PSU0435 PSU0437 PSU0438 PSU0441 PSU0445 PSU0449 PSU0450 PSU0451 PSU0452 PSU0454 PSU0455 PSU0458 PSU0461 PSU0462 PSU0464 PSU0466 PSU0468 PSU0470 PSU0472 PSU0478 PSU0479 PSU0480 PSU0482 PSU0483 PSU0487 PSU0488 PSU0490 PSU0492 PSU0493 PSU0494 PSU0495 PSU0499 PSU0501 PSU0502 PSU0503 PSU0504 PSU0505 PSU0506 PSU0508 PSU0511 PSU0513 PSU0514 PSU0517 PSU0519 PSU0521 PSU0522 PSU0523 PSU0524 PSU0527 PSU0529 PSU0531 PSU0533 PSU0535 PSU0536 PSU0537 PSU0540 PSU0542 PSU0543 PSU0545 PSU0546 PSU0549 PSU0551 PSU0553 PSU0554 PSU0557 PSU0561 PSU0562 PSU0565 PSU0566 PSU0568 PSU0569 PSU0570 PSU0571 PSU0575 PSU0576 PSU0586 PSU0593 PSU0597 PSU0598 PSU0603 PSU0604 PSU0606 PSU0609 PSU0610 PSU0612 PSU0616 PSU0617 PSU0620 PSU0621 PSU0623 PSU0624 PSU0626 PSU0629 PSU0630 PSU0631 PSU0632 PSU0634 PSU0637 PSU0639 PSU0641 PSU0642 PSU0643 PSU0645 PSU0646 PSU0647 PSU0648 PSU0649 PSU0650 PSU0651 PSU0652 PSU0654 PSU0655 PSU0659 PSU0661 PSU0662 PSU0663 PSU0665 PSU0667 PSU0668 PSU0669 PSU0671 PSU0672 PSU0673 PSU0674 PSU0675 PSU0677 PSU0680 PSU0682 PSU0683 PSU0684 PSU0686 PSU0687 PSU0689 PSU0690 PSU0691 PSU0696 PSU0697 PSU0699 PSU0701 PSU0702 PSU0704 PSU0705 PSU0706 PSU0709 PSU0710 PSU0712 PSU0714 PSU0716 PSU0717 PSU0718 PSU0719 PSU0720 PSU0721 PSU0724 PSU0725 PSU0727 PSU0728 PSU0729 PSU0730 PSU0731 PSU0733 PSU0734 PSU0736 PSU0737 PSU0738 PSU0741 PSU0742 PSU0743 PSU0744 PSU0745 PSU0749 PSU0750 PSU0751 PSU0753 PSU0756 PSU0757 PSU0758 PSU0759 PSU0760 PSU0763 PSU0764 PSU0765 PSU0766 PSU0767 PSU0769 PSU0770 PSU0771 PSU0772 PSU0773 PSU0776 PSU0780 PSU0781 PSU0782 PSU0783 PSU0784 PSU0787 PSU0788 PSU0789 PSU0790 PSU0791 PSU0792 PSU0794 PSU0798 PSU0799 PSU0804 PSU0806 PSU0807 PSU0808 PSU0810 PSU0811 PSU0813 PSU0814 PSU0815 PSU0816 PSU0818 PSU0821 PSU0822 PSU0824 PSU0825 PSU0828 PSU0830 PSU0831 PSU0833 PSU0834 PSU0837 PSU0840 PSU0843 PSU0844 PSU0847 PSU0849 PSU0851 PSU0853 PSU0855 PSU0856 PSU0858 PSU0860 PSU0862 PSU0863 PSU0864 PSU1060 PSU1095 PSU1372 PSU1373 PSU1374 PSU1381 PSU1392 PSU1399 PSU1414 PSU1421 PSU1422 PSU1430 PSU1432 PSU1470 PSU1473 PSU1490 PSU1526 PSU1540 PSU1549 PSU1553 PSU1556 PSU1561 PSU1564 PSU1576 PSU1591 PSU1609 PSU1613 PSU1625 PSU1626 PSU1630 PSU1638 PSU1639
1 rs13475697 0.01 3.385827 U H H H H B D B H B H H D H H H H H H H H B H H H H D H D B B D H H B H D H B H H H B B B D B H H D H D B H H H B H B B B B B B H H B D D H H D D H D D H H B D D B B D B B D B B H B B H D B H H H D H D B D B D H H D B D D H H H D B H B H D H D H D B D D D H H D H B B H H B H B H B D H D D D D H D H H H D B D H D H H D B D B B B D H H B D H H H H D H D H D H D H D D B H D B H D H D D H H H H H D D B H H D B H H H H D H H H D H B D D D H H H H B D H H H D H B B B D B H H H H B H H B H B D D D D H D H D H D B H H H B B B B B H U B H H B D H D H D H H B B B H H H H H D B H H H B H D H D B B D B H H B D H H H B B H H H D H B H B D H B H D B H B H H H B H B H D D B H D B H H D H H D D H H H H B B H D H D H H D D B D D H H D D H H B H H H H B H H D H D H B H D D H H D D B H H H H H H D B D H H B H B H H H H H D H B B D H H D D D B B H H B H H B H B B H B D H H H B B H D B B B D D B D H H B H D D H H H B H H D B D H B H D D B H H D H D H B H H H H H D H B D B H H H D H H B H H B D H D D B H D H D B H H H D H D H D D H B B D B H D B H D H H B B H H H H B H D H H B D B D H D D H B D H B H H H D D H D H
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 1668940c..03b24230 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -27,8 +27,12 @@ import string import collections import json +import cPickle as pickle import itertools +from redis import Redis +Redis = Redis() + from flask import Flask, g import reaper @@ -46,17 +50,18 @@ from pprint import pformat as pf # Used by create_database to instantiate objects DS_NAME_MAP = {} -def create_dataset(dataset_name): +def create_dataset(dataset_name, dataset_type = None): #print("dataset_name:", dataset_name) - query = """ - SELECT DBType.Name - FROM DBList, DBType - WHERE DBList.Name = '{}' and - DBType.Id = DBList.DBTypeId - """.format(escape(dataset_name)) - #print("query is: ", pf(query)) - dataset_type = g.db.execute(query).fetchone().Name + if not dataset_type: + query = """ + SELECT DBType.Name + FROM DBList, DBType + WHERE DBList.Name = '{}' and + DBType.Id = DBList.DBTypeId + """.format(escape(dataset_name)) + #print("query is: ", pf(query)) + dataset_type = g.db.execute(query).fetchone().Name #dataset_type = cursor.fetchone()[0] #print("[blubber] dataset_type:", pf(dataset_type)) @@ -69,6 +74,36 @@ def create_dataset(dataset_name): dataset_class = globals()[dataset_ob] return dataset_class(dataset_name) +def create_datasets_list(): + key = "all_datasets" + result = Redis.get(key) + + if result: + print("Cache hit!!!") + datasets = pickle.loads(result) + + else: + datasets = list() + with Bench("Creating DataSets object"): + 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): """Create an in clause for mysql""" in_clause = ', '.join("'{}'".format(x) for x in mescape(*items)) @@ -167,8 +202,8 @@ class DatasetGroup(object): self.incparentsf1 = False self.allsamples = None - - + + def get_markers(self): #print("self.species is:", self.species) if self.species == "human": @@ -222,6 +257,27 @@ class DatasetGroup(object): self.samplelist = list(genotype.prgy) +#class DataSets(object): +# """Builds a list of DataSets""" +# +# def __init__(self): +# self.datasets = list() +# + + + #query = """SELECT Name FROM ProbeSetFreeze + # UNION + # SELECT Name From PublishFreeze + # UNION + # SELECT Name From GenoFreeze""" + # + #for result in g.db.execute(query).fetchall(): + # dataset = DataSet(result.Name) + # self.datasets.append(dataset) + +#ds = DataSets() +#print("[orange] ds:", ds.datasets) + class DataSet(object): """ DataSet class defines a dataset in webqtl, can be either Microarray, @@ -234,6 +290,8 @@ class DataSet(object): assert name, "Need a name" self.name = name self.id = None + self.shortname = None + self.fullname = None self.type = None self.setup() @@ -293,7 +351,7 @@ class DataSet(object): self.name, self.name, self.name)) - #print("query_args are:", query_args) + print("query_args are:", query_args) #print(""" # SELECT Id, Name, FullName, ShortName @@ -301,17 +359,17 @@ class DataSet(object): # WHERE public > %s AND # (Name = '%s' OR FullName = '%s' OR ShortName = '%s') # """ % (query_args)) - - self.id, self.name, self.fullname, self.shortname = g.db.execute(""" - SELECT Id, Name, FullName, ShortName - FROM %s - WHERE public > %s AND - (Name = '%s' OR FullName = '%s' OR ShortName = '%s') - """ % (query_args)).fetchone() - - #self.cursor.execute(query) - #self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() + try: + self.id, self.name, self.fullname, self.shortname = g.db.execute(""" + SELECT Id, Name, FullName, ShortName + FROM %s + WHERE public > %s AND + (Name = '%s' OR FullName = '%s' OR ShortName = '%s') + """ % (query_args)).fetchone() + except TypeError: + print("Dataset {} is not yet available in GeneNetwork.".format(self.name)) + pass class PhenotypeDataSet(DataSet): DS_NAME_MAP['Publish'] = 'PhenotypeDataSet' @@ -940,6 +998,5 @@ def geno_mrna_confidentiality(ob): authorized_users) = result.fetchall()[0] if confidential: - # Allow confidential data later - NoConfindetialDataForYouTodaySorry + return True diff --git a/wqflask/base/species.py b/wqflask/base/species.py index 191f4535..ebc2bfed 100644 --- a/wqflask/base/species.py +++ b/wqflask/base/species.py @@ -56,6 +56,7 @@ class Chromosomes(object): InbredSet.Name = %s Order by OrderId """, self.dataset.group.name).fetchall() + print("group: ", self.dataset.group.name) print("bike:", results) for item in results: @@ -68,9 +69,14 @@ class Chromosomes(object): def set_mb_graph_interval(self): """Empirical megabase interval""" + if self.chromosomes: + self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12) + else: + self.mb_graph_interval = 1 + #if self.chromosomes: - assert self.chromosomes, "Have to add some code back in apparently to set it to 1" - self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12) + #assert self.chromosomes, "Have to add some code back in apparently to set it to 1" + #self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12) #else: #self.mb_graph_interval = 1 diff --git a/wqflask/cfg/default_settings.py b/wqflask/cfg/default_settings.py index 96f7f1a5..e638a9c0 100644 --- a/wqflask/cfg/default_settings.py +++ b/wqflask/cfg/default_settings.py @@ -13,3 +13,5 @@ SECURITY_REGISTERABLE = True SECURITY_RECOVERABLE = True SECURITY_EMAIL_SENDER = "no-reply@genenetwork.org" + +SECURITY_POST_LOGIN_VIEW = "/thank_you" diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 03059d68..11eca936 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -203,6 +203,13 @@ class CorrelationResults(object): # mb = trait_object.mb # ) + + + #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 #self.target_db_name = start_vars['corr_dataset'] diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index f76af374..504a67ce 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -162,8 +162,6 @@ class SearchResultPage(object): import redis Redis = redis.Redis() - - #def get_group_species_tree(self): # self.species_groups = collections.default_dict(list) # for key in self.results: diff --git a/wqflask/wqflask/static/new/javascript/login.coffee b/wqflask/wqflask/static/new/javascript/login.coffee index c49353d5..15dafd9a 100644 --- a/wqflask/wqflask/static/new/javascript/login.coffee +++ b/wqflask/wqflask/static/new/javascript/login.coffee @@ -13,8 +13,8 @@ $ -> - - $(document).on("click", ".modalize", modalize) + $(document).one("click", ".modalize", modalize) + console.log("Modalized click!!!") form_success = (data) -> $.colorbox( @@ -39,4 +39,4 @@ $ -> ) - $("form").on("submit", submit_form) + $("#colorbox form").on("submit", submit_form) diff --git a/wqflask/wqflask/static/new/javascript/login.js b/wqflask/wqflask/static/new/javascript/login.js index 6c6120ec..ce301353 100644 --- a/wqflask/wqflask/static/new/javascript/login.js +++ b/wqflask/wqflask/static/new/javascript/login.js @@ -14,7 +14,8 @@ } }); }; - $(document).on("click", ".modalize", modalize); + $(document).one("click", ".modalize", modalize); + console.log("Modalized click!!!"); form_success = function(data) { return $.colorbox({ open: true, @@ -38,7 +39,7 @@ success: form_success }); }; - return $("form").on("submit", submit_form); + return $("#colorbox form").on("submit", submit_form); }); }).call(this); diff --git a/wqflask/wqflask/static/new/javascript/thank_you.coffee b/wqflask/wqflask/static/new/javascript/thank_you.coffee new file mode 100644 index 00000000..975f85c6 --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/thank_you.coffee @@ -0,0 +1,4 @@ +$ -> + console.log("Starting transform") + $('#login_out').text('Sign out').attr('href', '/logout').removeClass('modalize') + console.log("Transformed to sign out I hope") diff --git a/wqflask/wqflask/static/new/javascript/thank_you.js b/wqflask/wqflask/static/new/javascript/thank_you.js new file mode 100644 index 00000000..2871dd2d --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/thank_you.js @@ -0,0 +1,10 @@ +// Generated by CoffeeScript 1.4.0 +(function() { + + $(function() { + console.log("Starting transform"); + $('#login_out').text('Sign out').attr('href', '/logout').removeClass('modalize'); + return console.log("Transformed to sign out I hope"); + }); + +}).call(this); diff --git a/wqflask/wqflask/templates/admin/group_manager.html b/wqflask/wqflask/templates/admin/group_manager.html new file mode 100644 index 00000000..df3eda33 --- /dev/null +++ b/wqflask/wqflask/templates/admin/group_manager.html @@ -0,0 +1,83 @@ +{% 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 id="dataset_list" 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 %} + +{% block js %} + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script> + <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> + <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> + <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + + <script type="text/javascript" charset="utf-8"> + $(document).ready( function () { + console.time("Creating table"); + $('#dataset_list').dataTable( { + "sDom": "Tftipr", + "oTableTools": { + "aButtons": [ + "copy", + "print", + { + "sExtends": "collection", + "sButtonText": 'Save <span class="caret" />', + "aButtons": [ "csv", "xls", "pdf" ] + } + ], + "sSwfPath": "/static/packages/TableTools/media/swf/copy_csv_xls_pdf.swf" + }, + "iDisplayLength": 50, + "bLengthChange": true, + "bDeferRender": true, + "bSortClasses": false + } ); + console.timeEnd("Creating table"); + }); + </script> +{% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 741c5425..cbed5859 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -70,9 +70,9 @@ </li> <li class=""> {% if g.identity.name=="anon" %} - <a id="login" class="modalize" href="/login">Sign in</a> + <a id="login_out" class="modalize" href="/login">Sign in</a> {% else %} - <a href="/logout">Sign out</a> + <a id="login_out" href="/logout">Sign out</a> {% endif %} </li> </ul> @@ -180,7 +180,7 @@ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script> <script language="javascript" type="text/javascript" src="/static/packages/colorbox/jquery.colorbox.js"></script> -<!-- <script type="text/javascript" src="/static/new/javascript/login.js"></script>--> + <script type="text/javascript" src="/static/new/javascript/login.js"></script> {% block js %} {% endblock %} diff --git a/wqflask/wqflask/templates/security/thank_you.html b/wqflask/wqflask/templates/security/thank_you.html new file mode 100644 index 00000000..dd6c7297 --- /dev/null +++ b/wqflask/wqflask/templates/security/thank_you.html @@ -0,0 +1,8 @@ +{% from "security/_macros.html" import render_only_errors %} +{% include "security/_messages.html" %} + +<div class="security_box"> + <h4>Thank you for signing in!</h4> +</div> + +<script src="/static/new/javascript/thank_you.js"></script> 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 b9aa3acf..813075b8 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -27,6 +27,7 @@ from flask import render_template, request, make_response, Response, Flask, g, c from wqflask import search_results from base.data_set import DataSet # Used by YAML in marker_regression +from base.data_set import create_datasets_list from wqflask.show_trait import show_trait from wqflask.show_trait import export_trait_data from wqflask.marker_regression import marker_regression @@ -53,6 +54,18 @@ def connect_db(): @app.route("/") def index_page(): print("Sending index_page") + #create_datasets_list() + #key = "all_datasets" + #result = Redis.get(key) + #if result: + # print("Cache hit!!!") + # result = pickle.loads(result) + #else: + # with Bench("Creating DataSets object"): + # ds = DataSets() + # 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") @app.route("/data_sharing") @@ -87,7 +100,7 @@ def search_page(): print("key is:", pf(key)) with Bench("Loading cache"): result = Redis.get(key) - + if result: print("Cache hit!!!") with Bench("Loading results"): @@ -97,9 +110,9 @@ def search_page(): print("request.args is", request.args) the_search = search_results.SearchResultPage(request.args) 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']: @@ -219,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"): @@ -249,11 +262,17 @@ def sharing_info_page(): return template_vars +# Take this out or secure it before going into production @app.route("/get_temp_data") def get_temp_data(): temp_uuid = request.args['key'] return flask.jsonify(temp_data.TempData(temp_uuid).get_all()) + +@app.route("/thank_you") +def thank_you(): + return render_template("security/thank_you.html") + @app.route("/manage/users") def manage_users(): template_vars = user_manager.UsersManager() @@ -264,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''' |