Skip to content

Commit 5085c35

Browse files
committed
more enhancements
1 parent 0df6666 commit 5085c35

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

qiita_pet/handlers/study_handlers/listing_handlers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def _build_study_info(studytype, user, results=None):
6767
infolist = []
6868
for row, info in enumerate(study_info):
6969
study = Study(info['study_id'])
70+
status = study.status
7071
# Just passing the email address as the name here, since
7172
# name is not a required field in qiita.qiita_user
7273
owner = study_person_linkifier((info['email'], info['email']))
@@ -77,7 +78,7 @@ def _build_study_info(studytype, user, results=None):
7778
for p in info['pmid']])
7879
else:
7980
pmids = ""
80-
if info["number_samples_collected"] is '':
81+
if info["number_samples_collected"] is None:
8182
info["number_samples_collected"] = "0"
8283
shared = _get_shared_links_for_study(study)
8384
meta_complete_glyph = "ok" if info["metadata_complete"] else "remove"
@@ -92,11 +93,11 @@ def _build_study_info(studytype, user, results=None):
9293
studytype, str(row), str(study.id), info["study_title"])
9394
meta_complete = "<span class='glyphicon glyphicon-%s'></span>" % \
9495
meta_complete_glyph
95-
if info["status"] == 'public':
96+
if status == 'public':
9697
shared = "Not Available"
9798
else:
9899
shared = ("<span id='shared_html_{0}'>{1}</span><br/>"
99-
"<a class='btn btn-primary' data-toggle='modal' "
100+
"<a class='btn btn-primary btn-xs' data-toggle='modal' "
100101
"data-target='#share-study-modal-view' "
101102
"onclick='modify_sharing({0});'>Modify</a>".format(
102103
study.id, shared))
@@ -112,7 +113,7 @@ def _build_study_info(studytype, user, results=None):
112113
"pi": PI,
113114
"pmid": pmids,
114115
"owner": owner,
115-
"status": study.status,
116+
"status": status,
116117
"abstract": info["study_abstract"]
117118

118119
})
@@ -207,7 +208,7 @@ def get(self, ignore):
207208
query = self.get_argument('query')
208209
echo = int(self.get_argument('sEcho'))
209210

210-
if user != self.current_user:
211+
if user != self.current_user.id:
211212
raise HTTPError(403, 'Unauthorized search!')
212213
res = None
213214
if query:

qiita_pet/test/test_study_handlers.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_build_study_info(self):
5757
self.assertEqual(obs, self.exp)
5858

5959
def test_build_study_info_new_study(self):
60-
Study(1).status = 'public'
60+
ProcessedData(1).status = 'public'
6161
info = {
6262
'timeseries_type_id': 1,
6363
'portal_type_id': 1,
@@ -85,10 +85,10 @@ def test_build_study_info_new_study(self):
8585
', 1)\'><span class=\'glyphicon glyphicon-file\' aria-hidden=\''
8686
'true\'></span></a> | <a href=\'/study/description/2\' id=\''
8787
'study1-title\'>test_study_1</a>',
88-
'num_raw_data': 0, 'id': 2L, 'num_samples': 'None',
88+
'num_raw_data': 0, 'id': 2, 'num_samples': '0',
8989
'shared': "<span id='shared_html_2'></span><br/><a class='btn "
90-
"btn-primary' data-toggle='modal' data-target='#share-study-modal-"
91-
"view' onclick='modify_sharing(2);'>Modify</a>",
90+
"btn-primary btn-xs' data-toggle='modal' data-target='#share-study"
91+
"-modal-view' onclick='modify_sharing(2);'>Modify</a>",
9292
'pmid': '', 'pi':
9393
'<a target="_blank" href="mailto:PI_dude@foo.bar">PIDude</a>'})
9494
self.assertEqual(obs, self.exp)
@@ -305,8 +305,8 @@ class TestSearchStudiesAJAX(TestHandlerBase):
305305
'bar</a>',
306306
'shared': '<span id=\'shared_html_1\'><a target="_blank" href="'
307307
'mailto:shared@foo.bar">Shared</a></span><br/><a class=\'btn '
308-
'btn-primary\' data-toggle=\'modal\' data-target=\'#share-study-'
309-
'modal-view\' onclick=\'modify_sharing(1);\'>Modify</a>',
308+
'btn-primary btn-xs\' data-toggle=\'modal\' data-target=\'#share'
309+
'-study-modal-view\' onclick=\'modify_sharing(1);\'>Modify</a>',
310310
'meta_complete': "<span class='glyphicon glyphicon-ok'>"
311311
"</span>",
312312
'pmid': '<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
@@ -361,6 +361,14 @@ def test_get_failure(self):
361361
self.assertEqual(response.body, 'Malformed search query. '
362362
'Please read "search help" and try again.')
363363

364+
response = self.get('/study/search/', {
365+
'type': 'standard',
366+
'user': 'FAKE@foo.bar',
367+
'query': 'ph',
368+
'sEcho': '1021'
369+
})
370+
self.assertEqual(response.code, 403)
371+
364372

365373
class TestMetadataSummaryHandler(TestHandlerBase):
366374
def test_error_prep_and_sample(self):

0 commit comments

Comments
 (0)