Skip to content

Commit a450aeb

Browse files
authored
Merge pull request #2242 from antgonza/fix-2225
fix #2225 and partial #2224
2 parents 4af4656 + 51ff4f9 commit a450aeb

File tree

6 files changed

+81
-71
lines changed

6 files changed

+81
-71
lines changed

qiita_db/test/test_util.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -800,36 +800,37 @@ def test_generate_study_list(self):
800800
qdb.user.User('shared@foo.bar'), 'test_study_1', info=info)
801801

802802
exp_info = [
803-
{'status': 'private', 'metadata_complete': True,
804-
'study_tags': None, 'publication_doi': [
805-
'10.100/123456', '10.100/7891011'],
806-
'study_title': ('Identification of the Microbiomes for '
807-
'Cannabis Soils'),
808-
'publication_pid': ['123456', '7891011'],
803+
{'status': 'private', 'study_title': (
804+
'Identification of the Microbiomes for Cannabis Soils'),
805+
'metadata_complete': True, 'publication_pid': [
806+
'123456', '7891011'], 'artifact_biom_ids': [4, 5, 6, 7],
809807
'ebi_submission_status': 'submitted', 'study_id': 1,
810-
'ebi_study_accession': 'EBI123456-BB',
808+
'ebi_study_accession': 'EBI123456-BB', 'owner': 'Dude',
811809
'shared': [('shared@foo.bar', 'Shared')],
812810
'study_abstract': (
813811
'This is a preliminary study to examine the microbiota '
814-
'associated with the Cannabis plant. Soils samples from the '
815-
'bulk soil, soil associated with the roots, and the '
816-
'rhizosphere were extracted and the DNA sequenced. Roots from '
817-
'three independent plants of different strains were examined. '
818-
'These roots were obtained November 11, 2011 from plants that '
819-
'had been harvested in the summer. Future studies will '
820-
'attempt to analyze the soils and rhizospheres from the same '
821-
'location at different time points in the plant lifecycle.'),
822-
'pi': ('PI_dude@foo.bar', 'PIDude'),
823-
'artifact_biom_ids': [4, 5, 6, 7],
812+
'associated with the Cannabis plant. Soils samples from '
813+
'the bulk soil, soil associated with the roots, and the '
814+
'rhizosphere were extracted and the DNA sequenced. Roots '
815+
'from three independent plants of different strains were '
816+
'examined. These roots were obtained November 11, 2011 from '
817+
'plants that had been harvested in the summer. Future studies '
818+
'will attempt to analyze the soils and rhizospheres from the '
819+
'same location at different time points in the plant '
820+
'lifecycle.'), 'pi': ('PI_dude@foo.bar', 'PIDude'),
821+
'publication_doi': ['10.100/123456', '10.100/7891011'],
822+
'study_alias': 'Cannabis Soils', 'study_tags': None,
824823
'number_samples_collected': 27},
825-
{'status': 'sandbox', 'metadata_complete': True,
826-
'study_tags': None, 'publication_doi': [],
827-
'study_title': 'test_study_1', 'publication_pid': [],
824+
{'status': 'sandbox', 'study_title': 'test_study_1',
825+
'metadata_complete': True, 'publication_pid': [],
826+
'artifact_biom_ids': None,
828827
'ebi_submission_status': 'not submitted',
829828
'study_id': new_study.id, 'ebi_study_accession': None,
830-
'shared': [], 'study_abstract': 'Some abstract goes here',
831-
'pi': ('lab_dude@foo.bar', 'LabDude'),
832-
'artifact_biom_ids': None, 'number_samples_collected': 0}]
829+
'owner': 'Shared', 'shared': [],
830+
'study_abstract': 'Some abstract goes here',
831+
'pi': ('lab_dude@foo.bar', 'LabDude'), 'publication_doi': [],
832+
'study_alias': 'TST', 'study_tags': None,
833+
'number_samples_collected': 0}]
833834
obs_info = qdb.util.generate_study_list([1, 2, 3, 4], True)
834835
self.assertEqual(obs_info, exp_info)
835836

qiita_db/util.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ def generate_study_list(study_ids, public_only=False):
12051205
-----
12061206
The main select might look scary but it's pretty simple:
12071207
- We select the requiered fields from qiita.study and qiita.study_person
1208-
SELECT metadata_complete, study_abstract, study_id,
1208+
SELECT metadata_complete, study_abstract, study_id, study_alias,
12091209
study_title, ebi_study_accession, ebi_submission_status,
12101210
qiita.study_person.name AS pi_name,
12111211
qiita.study_person.email AS pi_email,
@@ -1235,10 +1235,13 @@ def generate_study_list(study_ids, public_only=False):
12351235
- all study tags
12361236
(SELECT array_agg(study_tag) FROM qiita.per_study_tags
12371237
WHERE study_id=qiita.study.study_id) AS study_tags
1238+
- study owner
1239+
(SELECT name FROM qiita.qiita_user
1240+
WHERE email=qiita.study.email) AS owner
12381241
"""
12391242
with qdb.sql_connection.TRN:
12401243
sql = """
1241-
SELECT metadata_complete, study_abstract, study_id,
1244+
SELECT metadata_complete, study_abstract, study_id, study_alias,
12421245
study_title, ebi_study_accession, ebi_submission_status,
12431246
qiita.study_person.name AS pi_name,
12441247
qiita.study_person.email AS pi_email,
@@ -1261,7 +1264,9 @@ def generate_study_list(study_ids, public_only=False):
12611264
LEFT JOIN qiita.qiita_user USING (email)
12621265
WHERE study_id=qiita.study.study_id) AS shared_with_email,
12631266
(SELECT array_agg(study_tag) FROM qiita.per_study_tags
1264-
WHERE study_id=qiita.study.study_id) AS study_tags
1267+
WHERE study_id=qiita.study.study_id) AS study_tags,
1268+
(SELECT name FROM qiita.qiita_user
1269+
WHERE email=qiita.study.email) AS owner
12651270
FROM qiita.study
12661271
LEFT JOIN qiita.study_person ON (
12671272
study_person_id=principal_investigator_id)
@@ -1303,6 +1308,8 @@ def generate_study_list(study_ids, public_only=False):
13031308
del info["shared_with_email"]
13041309

13051310
infolist.append({
1311+
'owner': info['owner'],
1312+
'study_alias': info['study_alias'],
13061313
'metadata_complete': info['metadata_complete'],
13071314
'publication_pid': info['publication_pid'],
13081315
'ebi_submission_status': info['ebi_submission_status'],

qiita_pet/handlers/api_proxy/tests/test_studies.py

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,16 @@ def test_study_get_req(self):
5050
obs = study_get_req(1, 'test@foo.bar')
5151
exp = {
5252
'status': 'success',
53-
'message': '',
5453
'study_info': {
55-
'mixs_compliant': True,
56-
'metadata_complete': True,
57-
'reprocess': False,
58-
'emp_person_id': 2,
59-
'number_samples_promised': 27,
60-
'funding': None,
61-
'vamps_id': None,
54+
'mixs_compliant': True, 'metadata_complete': True,
55+
'reprocess': False, 'owner': 'test@foo.bar',
56+
'emp_person_id': 2, 'number_samples_promised': 27,
57+
'funding': None, 'show_biom_download_button': True,
58+
'publication_pid': ['123456', '7891011'], 'vamps_id': None,
6259
'first_contact': datetime(2014, 5, 19, 16, 10),
63-
'timeseries_type_id': 1,
64-
'study_abstract':
60+
'ebi_submission_status': 'submitted',
61+
'show_raw_download_button': True, 'timeseries_type_id': 1,
62+
'study_abstract': (
6563
'This is a preliminary study to examine the microbiota '
6664
'associated with the Cannabis plant. Soils samples from '
6765
'the bulk soil, soil associated with the roots, and the '
@@ -71,33 +69,25 @@ def test_study_get_req(self):
7169
'from plants that had been harvested in the summer. '
7270
'Future studies will attempt to analyze the soils and '
7371
'rhizospheres from the same location at different time '
74-
'points in the plant lifecycle.',
75-
'status': 'private',
76-
'spatial_series': False,
77-
'study_description': 'Analysis of the Cannabis Plant '
78-
'Microbiome',
79-
'shared_with': ['shared@foo.bar'],
80-
'lab_person': {'affiliation': 'knight lab',
81-
'name': 'LabDude',
82-
'email': 'lab_dude@foo.bar'},
83-
'principal_investigator': {'affiliation': 'Wash U',
84-
'name': 'PIDude',
85-
'email': 'PI_dude@foo.bar'},
86-
'study_alias': 'Cannabis Soils',
87-
'study_id': 1,
72+
'points in the plant lifecycle.'),
73+
'status': 'private', 'spatial_series': False,
74+
'study_description': (
75+
'Analysis of the Cannabis Plant Microbiome'),
76+
'shared_with': ['shared@foo.bar'], 'publication_doi': [
77+
'10.100/123456', '10.100/7891011'],
78+
'has_access_to_raw_data': True, 'lab_person': {
79+
'affiliation': 'knight lab', 'name': 'LabDude',
80+
'email': 'lab_dude@foo.bar'},
81+
'principal_investigator': {
82+
'affiliation': 'Wash U', 'name': 'PIDude',
83+
'email': 'PI_dude@foo.bar'},
84+
'study_alias': 'Cannabis Soils', 'study_id': 1,
8885
'most_recent_contact': datetime(2014, 5, 19, 16, 11),
89-
'publication_doi': ['10.100/123456', '10.100/7891011'],
90-
'publication_pid': ['123456', '7891011'],
91-
'num_samples': 27,
92-
'study_title': 'Identification of the Microbiomes for '
93-
'Cannabis Soils',
94-
'number_samples_collected': 27,
95-
'owner': 'test@foo.bar',
96-
'ebi_submission_status': 'submitted',
97-
'has_access_to_raw_data': True,
98-
'show_biom_download_button': True,
99-
'show_raw_download_button': True,
100-
'ebi_study_accession': 'EBI123456-BB'},
86+
'ebi_study_accession': 'EBI123456-BB', 'num_samples': 27,
87+
'study_title': (
88+
'Identification of the Microbiomes for Cannabis Soils'),
89+
'number_samples_collected': 27},
90+
'message': '',
10191
'editable': True}
10292
self.assertEqual(obs, exp)
10393

@@ -139,6 +129,8 @@ def test_study_get_req(self):
139129
'study_description': 'DESC',
140130
'shared_with': [],
141131
'lab_person': None,
132+
'study_alias': "FCM",
133+
'owner': 'Dude',
142134
'principal_investigator': {'affiliation': 'Wash U',
143135
'name': 'PIDude',
144136
'email': 'PI_dude@foo.bar'},

qiita_pet/handlers/study_handlers/tests/test_listing_handlers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def setUp(self):
3232

3333
self.single_exp = {
3434
'study_id': 1,
35+
'owner': 'Dude',
36+
'study_alias': 'Cannabis Soils',
3537
'status': 'private',
3638
'study_abstract':
3739
'This is a preliminary study to examine the microbiota '
@@ -113,8 +115,8 @@ def test_build_study_info_empty_study(self):
113115
'study_alias': 'alias',
114116
'study_abstract': 'abstract'}
115117
Study.create(User('test@foo.bar'), "My study", info=info)
116-
obs = _build_study_info(User('test@foo.bar'), 'user')
117118

119+
obs = _build_study_info(User('test@foo.bar'), 'user')
118120
self.exp.append({
119121
'metadata_complete': False,
120122
'ebi_submission_status':
@@ -126,6 +128,8 @@ def test_build_study_info_empty_study(self):
126128
'publication_doi': [],
127129
'study_abstract': 'abstract',
128130
'study_id': 2,
131+
'owner': 'Dude',
132+
'study_alias': 'alias',
129133
'ebi_study_accession': None,
130134
'study_title': 'My study',
131135
'study_tags': None,
@@ -260,6 +264,8 @@ def setUp(self):
260264
'metadata_complete': True,
261265
'ebi_submission_status': 'submitted',
262266
'study_id': 1,
267+
'study_alias': 'Cannabis Soils',
268+
'owner': 'Dude',
263269
'ebi_study_accession': 'EBI123456-BB',
264270
'shared': ('<a target="_blank" href="mailto:shared@foo.bar">'
265271
'Shared</a>'),

qiita_pet/support_files/doc/source/tutorials/sharing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ permissions that the owner of the Study has. These permissions are:
2727
Sharing a Study
2828
---------------
2929

30-
In the “Your Studies (includes shared with you)” section of the Studies List
30+
In the “Your Studies” section of the Studies List
3131
you have a “Shared With These Users” column that lists all User names that
3232
your study is shared with. You can click on the “Modify” button and add/remove
3333
users. See below.
@@ -47,5 +47,5 @@ will have a link to share it. See below
4747

4848
.. figure:: images/sharing_study.gif
4949
:align: center
50-
50+
5151
Analysis sharing example

qiita_pet/templates/list_studies.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@
129129
{ "data": "pi" },
130130
{ "data": "pubs" },
131131
{ "data": "status" },
132-
{ "data": "ebi_info" }
133-
],
132+
{ "data": "ebi_info" },
133+
{ "data": "study_alias" }],
134134
columnDefs: [
135135
{type:'natural', targets:[2,6,7]},
136-
{"targets": [ 2 ], "visible": false},
136+
{"targets": [ 2, 10 ], "visible": false},
137137
// render zero
138138
{"render": function ( data, type, row, meta ) {
139139
if (data !== null && data !== undefined && data.length != 0){
@@ -166,7 +166,10 @@
166166
{"render": function ( data, type, row, meta ) {
167167
var glyph = 'remove';
168168
if(data === true) { glyph = 'ok' }
169-
return "<span id='shared_html_"+ row.study_id +"'>"+ data +"</span><br/><a class='btn btn-primary btn-xs' data-toggle='modal' data-target='#share-study-modal-view' onclick='modify_sharing("+ row.study_id +");'>Modify</a>";
169+
result = "<a class='btn btn-primary btn-xs' data-toggle='modal' data-target='#share-study-modal-view' onclick='modify_sharing("+ row.study_id +");'>Modify</a><br/>";
170+
result += "<b>Owner:</b> " + row.owner + "</br>";
171+
result += "<span id='shared_html_"+ row.study_id +"'>"+ data +"</span>";
172+
return result;
170173
}, targets: [5]},
171174
],
172175
"language": {
@@ -408,7 +411,7 @@ <h5 class="gray-msg">
408411
</h5>
409412
<select class="js-select2-multiple form-control" id="study_tags_multiple" multiple="multiple" style="width: 100%"></select>
410413

411-
<h3 class="gray-msg">Your Studies (includes shared with you)</h3>
414+
<h3 class="gray-msg">Your Studies</h3>
412415
<table id="user-studies-table" class="table table-bordered gray-msg">
413416
<thead>
414417
<tr>
@@ -422,10 +425,11 @@ <h3 class="gray-msg">Your Studies (includes shared with you)</h3>
422425
<th>Publications</th>
423426
<th>Status</th>
424427
<th>Qiita EBI submission</th>
428+
<th>Study Alias</th>
425429
</tr>
426430
</thead>
427431
</table>
428-
<h3 class="gray-msg">Other Studies</h3>
432+
<h3 class="gray-msg">Public Studies</h3>
429433
<table id="studies-table" class="table table-bordered gray-msg">
430434
<thead>
431435
<tr>

0 commit comments

Comments
 (0)