Skip to content

DataTables load using AJAX, Search by metadata on studies page #1006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Apr 1, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
616300f
add get_info to Studies object
squirrelo Mar 19, 2015
d595016
expand tests
squirrelo Mar 19, 2015
90313f7
use get_info in listing handler
squirrelo Mar 19, 2015
fb5eef3
condense view studies pages
squirrelo Mar 19, 2015
1ffd4bc
clean up naming, add form elements
squirrelo Mar 19, 2015
16257c4
load study tables through ajax
squirrelo Mar 19, 2015
9ccc098
add message for zero results
squirrelo Mar 19, 2015
abeb46f
add search and retrieve to page
squirrelo Mar 20, 2015
259bec2
fix bug in joins
squirrelo Mar 20, 2015
b8472a8
add full ajax search support
squirrelo Mar 20, 2015
cf6ca77
add error handling to datatables
squirrelo Mar 20, 2015
cd4f66e
alter/add tests for handlers to reflect changes
squirrelo Mar 20, 2015
ce4d334
fix tests
squirrelo Mar 20, 2015
58b28cd
implement Jess' suggestions
squirrelo Mar 21, 2015
1872555
Merge branch 'master' of https://github.com/biocore/qiita into cart
squirrelo Mar 22, 2015
4b7ffcf
remove unneeded format loop, format datatables better
squirrelo Mar 24, 2015
515f0f6
update tests
squirrelo Mar 24, 2015
21b17d6
Merge branch 'master' of https://github.com/biocore/qiita into cart
squirrelo Mar 24, 2015
04f87f4
specific ordering for PMIDs for testing
squirrelo Mar 24, 2015
ee4c9e2
flake8
squirrelo Mar 24, 2015
ef16d18
address issues
squirrelo Mar 26, 2015
fbe7c74
address comments
squirrelo Mar 26, 2015
e0f22d0
merge upstream/master
squirrelo Mar 27, 2015
0df6666
fix merge issues
squirrelo Mar 27, 2015
5085c35
more enhancements
squirrelo Mar 27, 2015
ea69fe8
address comments
squirrelo Mar 28, 2015
3a12f87
update tests
squirrelo Mar 28, 2015
25ae8f2
update schema and html files
squirrelo Mar 29, 2015
e01e224
fix search disabled and clearing table search
squirrelo Apr 1, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add full ajax search support
  • Loading branch information
squirrelo committed Mar 20, 2015
commit b8472a82bc588daed1c351d5436677d790f8eff0
16 changes: 10 additions & 6 deletions qiita_pet/handlers/study_handlers/listing_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from qiita_db.user import User
from qiita_db.study import Study, StudyPerson
from qiita_db.search import QiitaStudySearch
from qiita_db.metadata_template import SampleTemplate
from qiita_db.util import get_table_cols
from qiita_pet.handlers.base_handlers import BaseHandler
from qiita_pet.handlers.util import study_person_linkifier, pubmed_linkifier

Expand Down Expand Up @@ -53,10 +55,8 @@ def _build_study_info(studytype, user, studies=None):
studylist = user.user_studies | Study.get_by_status('public')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if possible, it would be nice to stick with either operators (this line), or methods (line 53), to improve consistency within the method being worked on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will stick with methods, since they are more universal.

elif studytype == "shared":
studylist = user.shared_studies

if not studylist:
return set()

StudyTuple = namedtuple('StudyInfo', 'id title meta_complete '
'num_samples_collected shared num_raw_data pi '
'pmids owner status abstract')
Expand All @@ -72,8 +72,11 @@ def _build_study_info(studytype, user, studies=None):
owner = study_person_linkifier((info['email'], info['email']))
PI = StudyPerson(info['principal_investigator_id'])
PI = study_person_linkifier((PI.email, PI.name))
pmids = ", ".join([pubmed_linkifier([p])
for p in info['pmid']])
if info['pmid'] is not None:
pmids = ", ".join([pubmed_linkifier([p])
for p in info['pmid']])
else:
pmids = ""
shared = _get_shared_links_for_study(study)
infolist.add(StudyTuple(
study.id, study.title, info["metadata_complete"],
Expand All @@ -95,7 +98,9 @@ class ListStudiesHandler(BaseHandler):
def get(self):
all_emails_except_current = yield Task(self._get_all_emails)
all_emails_except_current.remove(self.current_user.id)
self.render('list_studies.html',
availmeta = SampleTemplate.metadata_headers() +\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

availmeta is not pep8 -> avail_meta

get_table_cols("study")
self.render('list_studies.html', availmeta=availmeta,
all_emails_except_current=all_emails_except_current)

def _get_all_emails(self, callback):
Expand Down Expand Up @@ -177,7 +182,6 @@ def get(self, ignore):
else:
# show everything
info = _build_study_info(search_type, self.current_user)
print ">>>>>AJAX", len(info)
# build the table json
results = {
"sEcho": echo,
Expand Down
21 changes: 19 additions & 2 deletions qiita_pet/templates/list_studies.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@

});
}

function add_metacat(metacat) {
document.getElementById('searchbox').value += (" " + metacat);
}
</script>

{% end %}
Expand All @@ -76,10 +80,10 @@
<div class="row">
<div class="col-sm-12">
<h1>Search</h1>
<p><a href="#" data-toggle="modal" data-target="#searchexample">Search help</a></p>
<p><a href="#" data-toggle="modal" data-target="#searchexample">Search help</a> | <a href="#" data-toggle="modal" data-target="#availmeta">Available Metadata</a></p>
<form id="search-form" name="search-form" class="form-inline">
<input type="textbox" id="searchbox" name="searchbox" class="form-control" style="width:80%;white-space:nowrap;" />
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" id="submit-button" class="btn btn-default">Submit</button>
</form>
</div>
<div class="col-sm-12" id="searchmsg" name="searchmsg"></div>
Expand Down Expand Up @@ -211,4 +215,17 @@ <h4 class="modal-title" id="myModalLabel">Modify Sharing Settings</h4>
</div>
</div>
</div>
<!--Available metadata modal-->
<div class="modal fade seaerch-example-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="availmeta">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header"><h2>Available metadata<h2></div>
<div class="modal-body">
{% for meta in availmeta %}
<a href="#" onclick="add_metacat('{{meta}}')">{{meta}}</a><br />
{% end %}
</div>
</div>
</div>
</div>
{% end %}