about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZachary Sloan2013-05-16 23:31:54 +0000
committerZachary Sloan2013-05-16 23:31:54 +0000
commit04b61737236b837e91355b66cbaab3549bc39140 (patch)
treecb0effc42a87a0780ed2091813b4dfe9f7ccf2a7
parent5a3f413da480123e3ad943b5f556e0a557f185cc (diff)
downloadgenenetwork2-04b61737236b837e91355b66cbaab3549bc39140.tar.gz
Made the first level of quick search tabs species, followed by
trait type (was the opposite before Rob commented on it earlier
today)
-rw-r--r--wqflask/wqflask/search_results.py19
-rw-r--r--wqflask/wqflask/templates/quick_search.html86
2 files changed, 45 insertions, 60 deletions
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index 5f3c036f..9b2751e0 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -74,7 +74,6 @@ class SearchResultPage(object):
             self.search_terms = kw['q']
             print("self.search_terms is: ", self.search_terms)
             self.quick_search()
-            self.get_group_species_tree()
         else:
             self.results = []
             #self.quick_search = False
@@ -144,12 +143,18 @@ class SearchResultPage(object):
             this_result['result_fields'] = json.loads(dbresult.result_fields)
             this_species = this_result['result_fields']['species']
             this_group = this_result['result_fields']['group_name']
-            if type_dict[dbresult.table_name] not in self.species_groups:
-                self.species_groups[type_dict[dbresult.table_name]] = {}
-            if this_species not in self.species_groups[type_dict[dbresult.table_name]]:
-                self.species_groups[type_dict[dbresult.table_name]][this_species] = collections.defaultdict(list)
-            if this_group not in self.species_groups[type_dict[dbresult.table_name]][this_species]:
-                self.species_groups[type_dict[dbresult.table_name]][this_species].append(this_group)
+            if this_species not in self.species_groups:
+                self.species_groups[this_species] = {}
+            if type_dict[dbresult.table_name] not in self.species_groups[this_species]:
+                self.species_groups[this_species][type_dict[dbresult.table_name]] = []
+            if this_group not in self.species_groups[this_species][type_dict[dbresult.table_name]]:
+                self.species_groups[this_species][type_dict[dbresult.table_name]].append(this_group)
+            #if type_dict[dbresult.table_name] not in self.species_groups:
+            #    self.species_groups[type_dict[dbresult.table_name]] = {}
+            #if this_species not in self.species_groups[type_dict[dbresult.table_name]]:
+            #    self.species_groups[type_dict[dbresult.table_name]][this_species] = []
+            #if this_group not in self.species_groups[type_dict[dbresult.table_name]][this_species]:
+            #    self.species_groups[type_dict[dbresult.table_name]][this_species].append(this_group)
             self.results[type_dict[dbresult.table_name]].append(this_result)
             
         #print("results: ", pf(self.results['phenotype']))
diff --git a/wqflask/wqflask/templates/quick_search.html b/wqflask/wqflask/templates/quick_search.html
index 9d5b0c74..5877a840 100644
--- a/wqflask/wqflask/templates/quick_search.html
+++ b/wqflask/wqflask/templates/quick_search.html
@@ -25,33 +25,31 @@
             </li>
             {% endif %}
         </ul>
-        
-        <p>To study a record, click on its ID below.<br />
-        Check records below and click Add button to add to selection.</p>
 
-        <div class="tabbable"> <!-- Only required for left/right tabs -->
+        <div id="species_level" class="tabbable"> <!-- Only required for left/right tabs -->
             <ul class="nav nav-tabs">
-                {% if results.phenotype %}
-                <li class="active"> <a href="#tab1" data-toggle="tab">Phenotype</a></li>
-                {% endif %}
-                {% if results.mrna_assay %}
-                <li>                <a href="#tab2" data-toggle="tab">mRNA Assay</a></li>
-                {% endif %}
-                {% if results.genotype %}
-                <li>                <a href="#tab3" data-toggle="tab">Genotype</a></li>
-                {% endif %}
+                {% for species in species_groups %}
+                <li> <a href="#tab{{ loop.index }}" data-toggle="tab">{{ species }}</a></li>
+                {% endfor %}
             </ul>
             <div class="tab-content">
-                <div class="tab-pane active" id="tab1">
-                    <div class="tabbable tabs-left">
+                {% for species in species_groups %}
+                <div class="tab-pane" id="tab{{ loop.index }}">
+                    <div id="trait_type_level" class="tabbable tabs-left">
                         <ul class="nav nav-tabs">
-                            {% for species in species_groups.phenotype %}
-                            <li> <a href="#tab1_{{ loop.index }}" data-toggle="tab">{{ species }}</a></li>
-                            {% endfor %}
+                            {% if species_groups[species]['phenotype'] %}
+                            <li> <a href="#tab{{ loop.index }}_1" data-toggle="tab">Phenotype</a></li>
+                            {% endif %}
+                            {% if species_groups[species]['mrna_assay'] %}
+                            <li> <a href="#tab{{ loop.index }}_2" data-toggle="tab">mRNA Assay</a></li>
+                            {% endif %}
+                            {% if species_groups[species]['genotype'] %}
+                            <li> <a href="#tab{{ loop.index }}_3" data-toggle="tab">Genotype</a></li>
+                            {% endif %}
                         </ul>
                         <div class="tab-content">
-                            {% for species in species_groups.phenotype %}
-                            <div class="tab-pane active" id="tab{{ loop.index }}">
+                            {% if species_groups[species]['phenotype'] %}
+                            <div class="tab-pane active" id="tab{{ loop.index }}_1">
                                 <table id="pheno_results" class="table table-hover table-striped table-bordered">
                                     <thead>
                                         <tr>
@@ -85,20 +83,9 @@
                                     </tbody>
                                 </table>
                             </div>
-                            {% endfor %}
-                        </div>
-                    </div>
-                </div>
-                <div class="tab-pane active" id="tab2">
-                    <div class="tabbable tabs-left">
-                        <ul class="nav nav-tabs">
-                            {% for species in species_groups.mrna_assay %}
-                            <li> <a href="#tab2_{{ loop.index }}" data-toggle="tab">{{ species }}</a></li>
-                            {% endfor %}
-                        </ul>
-                        <div class="tab-content">
-                            {% for species in species_groups.mrna_assay %}
-                            <div class="tab-pane active" id="tab{{ loop.index }}">
+                            {% endif %}
+                            {% if species_groups[species]['mrna_assay'] %}
+                            <div class="tab-pane" id="tab{{ loop.index }}_2">
                                 <table id="mrna_assay_results" class="table table-hover table-striped table-bordered">
                                     <thead>
                                         <tr>
@@ -136,20 +123,9 @@
                                     </tbody>
                                 </table>       
                             </div>
-                            {% endfor %}
-                        </div>
-                    </div>
-                </div>
-                <div class="tab-pane active" id="tab3">
-                    <div class="tabbable tabs-left">
-                        <ul class="nav nav-tabs">
-                            {% for species in species_groups.genotype %}
-                            <li> <a href="#tab3_{{ loop.index }}" data-toggle="tab">{{ species }}</a></li>
-                            {% endfor %}
-                        </ul>
-                        <div class="tab-content">
-                            {% for species in species_groups.genotype %}
-                            <div class="tab-pane active" id="tab{{ loop.index }}">
+                            {% endif %}
+                            {% if species_groups[species]['genotype'] %}
+                            <div class="tab-pane" id="tab{{ loop.index }}_3">
                                 <table id="geno_results" class="table table-hover table-striped table-bordered">
                                     <thead>
                                         <tr>
@@ -179,14 +155,19 @@
                                     </tbody>
                                 </table>   
                             </div>
-                            {% endfor %}
+                            {% endif %}
                         </div>
                     </div>
                 </div>
+                {% endfor %}
             </div>
         </div>
     </div>
-    
+
+<!-- End of body -->
+
+{% endblock %}
+
                 {#
                     <table id="pheno_results" class="table table-hover table-striped table-bordered">
                         <thead>
@@ -285,9 +266,6 @@
                 </div>
                 #}
 
-<!-- End of body -->
-
-{% endblock %}
 
 {% block js %}  
     <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script>
@@ -299,6 +277,8 @@
     
     <script type="text/javascript" charset="utf-8">
         $(document).ready( function () {
+            $('#species_level ul li:first').addClass('active');
+            $('#trait_type_level ul li:first').addClass('active');
             console.time("Creating table");
             $('#pheno_results, #mrna_assay_results, #geno_results').dataTable( {
                 //"sDom": "<<'span3'l><'span3'T><'span4'f>'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>",