Skip to content

fix #2225 and partial #2224 #2242

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 5 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 24 additions & 23 deletions qiita_db/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,36 +800,37 @@ def test_generate_study_list(self):
qdb.user.User('shared@foo.bar'), 'test_study_1', info=info)

exp_info = [
{'status': 'private', 'metadata_complete': True,
'study_tags': None, 'publication_doi': [
'10.100/123456', '10.100/7891011'],
'study_title': ('Identification of the Microbiomes for '
'Cannabis Soils'),
'publication_pid': ['123456', '7891011'],
{'status': 'private', 'study_title': (
'Identification of the Microbiomes for Cannabis Soils'),
'metadata_complete': True, 'publication_pid': [
'123456', '7891011'], 'artifact_biom_ids': [4, 5, 6, 7],
'ebi_submission_status': 'submitted', 'study_id': 1,
'ebi_study_accession': 'EBI123456-BB',
'ebi_study_accession': 'EBI123456-BB', 'owner': 'Dude',
'shared': [('shared@foo.bar', 'Shared')],
'study_abstract': (
'This is a preliminary study to examine the microbiota '
'associated with the Cannabis plant. Soils samples from the '
'bulk soil, soil associated with the roots, and the '
'rhizosphere were extracted and the DNA sequenced. Roots from '
'three independent plants of different strains were examined. '
'These roots were obtained November 11, 2011 from plants that '
'had been harvested in the summer. Future studies will '
'attempt to analyze the soils and rhizospheres from the same '
'location at different time points in the plant lifecycle.'),
'pi': ('PI_dude@foo.bar', 'PIDude'),
'artifact_biom_ids': [4, 5, 6, 7],
'associated with the Cannabis plant. Soils samples from '
'the bulk soil, soil associated with the roots, and the '
'rhizosphere were extracted and the DNA sequenced. Roots '
'from three independent plants of different strains were '
'examined. These roots were obtained November 11, 2011 from '
'plants that had been harvested in the summer. Future studies '
'will attempt to analyze the soils and rhizospheres from the '
'same location at different time points in the plant '
'lifecycle.'), 'pi': ('PI_dude@foo.bar', 'PIDude'),
'publication_doi': ['10.100/123456', '10.100/7891011'],
'study_alias': 'Cannabis Soils', 'study_tags': None,
'number_samples_collected': 27},
{'status': 'sandbox', 'metadata_complete': True,
'study_tags': None, 'publication_doi': [],
'study_title': 'test_study_1', 'publication_pid': [],
{'status': 'sandbox', 'study_title': 'test_study_1',
'metadata_complete': True, 'publication_pid': [],
'artifact_biom_ids': None,
'ebi_submission_status': 'not submitted',
'study_id': new_study.id, 'ebi_study_accession': None,
'shared': [], 'study_abstract': 'Some abstract goes here',
'pi': ('lab_dude@foo.bar', 'LabDude'),
'artifact_biom_ids': None, 'number_samples_collected': 0}]
'owner': 'Shared', 'shared': [],
'study_abstract': 'Some abstract goes here',
'pi': ('lab_dude@foo.bar', 'LabDude'), 'publication_doi': [],
'study_alias': 'TST', 'study_tags': None,
'number_samples_collected': 0}]
obs_info = qdb.util.generate_study_list([1, 2, 3, 4], True)
self.assertEqual(obs_info, exp_info)

Expand Down
13 changes: 10 additions & 3 deletions qiita_db/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ def generate_study_list(study_ids, public_only=False):
-----
The main select might look scary but it's pretty simple:
- We select the requiered fields from qiita.study and qiita.study_person
SELECT metadata_complete, study_abstract, study_id,
SELECT metadata_complete, study_abstract, study_id, study_alias,
study_title, ebi_study_accession, ebi_submission_status,
qiita.study_person.name AS pi_name,
qiita.study_person.email AS pi_email,
Expand Down Expand Up @@ -1235,10 +1235,13 @@ def generate_study_list(study_ids, public_only=False):
- all study tags
(SELECT array_agg(study_tag) FROM qiita.per_study_tags
WHERE study_id=qiita.study.study_id) AS study_tags
- study owner
(SELECT name FROM qiita.qiita_user
WHERE email=qiita.study.email) AS owner
"""
with qdb.sql_connection.TRN:
sql = """
SELECT metadata_complete, study_abstract, study_id,
SELECT metadata_complete, study_abstract, study_id, study_alias,
study_title, ebi_study_accession, ebi_submission_status,
qiita.study_person.name AS pi_name,
qiita.study_person.email AS pi_email,
Expand All @@ -1261,7 +1264,9 @@ def generate_study_list(study_ids, public_only=False):
LEFT JOIN qiita.qiita_user USING (email)
WHERE study_id=qiita.study.study_id) AS shared_with_email,
(SELECT array_agg(study_tag) FROM qiita.per_study_tags
WHERE study_id=qiita.study.study_id) AS study_tags
WHERE study_id=qiita.study.study_id) AS study_tags,
(SELECT name FROM qiita.qiita_user
WHERE email=qiita.study.email) AS owner
FROM qiita.study
LEFT JOIN qiita.study_person ON (
study_person_id=principal_investigator_id)
Expand Down Expand Up @@ -1303,6 +1308,8 @@ def generate_study_list(study_ids, public_only=False):
del info["shared_with_email"]

infolist.append({
'owner': info['owner'],
'study_alias': info['study_alias'],
'metadata_complete': info['metadata_complete'],
'publication_pid': info['publication_pid'],
'ebi_submission_status': info['ebi_submission_status'],
Expand Down
64 changes: 28 additions & 36 deletions qiita_pet/handlers/api_proxy/tests/test_studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,16 @@ def test_study_get_req(self):
obs = study_get_req(1, 'test@foo.bar')
exp = {
'status': 'success',
'message': '',
'study_info': {
'mixs_compliant': True,
'metadata_complete': True,
'reprocess': False,
'emp_person_id': 2,
'number_samples_promised': 27,
'funding': None,
'vamps_id': None,
'mixs_compliant': True, 'metadata_complete': True,
'reprocess': False, 'owner': 'test@foo.bar',
'emp_person_id': 2, 'number_samples_promised': 27,
'funding': None, 'show_biom_download_button': True,
'publication_pid': ['123456', '7891011'], 'vamps_id': None,
'first_contact': datetime(2014, 5, 19, 16, 10),
'timeseries_type_id': 1,
'study_abstract':
'ebi_submission_status': 'submitted',
'show_raw_download_button': True, 'timeseries_type_id': 1,
'study_abstract': (
'This is a preliminary study to examine the microbiota '
'associated with the Cannabis plant. Soils samples from '
'the bulk soil, soil associated with the roots, and the '
Expand All @@ -71,33 +69,25 @@ def test_study_get_req(self):
'from plants that had been harvested in the summer. '
'Future studies will attempt to analyze the soils and '
'rhizospheres from the same location at different time '
'points in the plant lifecycle.',
'status': 'private',
'spatial_series': False,
'study_description': 'Analysis of the Cannabis Plant '
'Microbiome',
'shared_with': ['shared@foo.bar'],
'lab_person': {'affiliation': 'knight lab',
'name': 'LabDude',
'email': 'lab_dude@foo.bar'},
'principal_investigator': {'affiliation': 'Wash U',
'name': 'PIDude',
'email': 'PI_dude@foo.bar'},
'study_alias': 'Cannabis Soils',
'study_id': 1,
'points in the plant lifecycle.'),
'status': 'private', 'spatial_series': False,
'study_description': (
'Analysis of the Cannabis Plant Microbiome'),
'shared_with': ['shared@foo.bar'], 'publication_doi': [
'10.100/123456', '10.100/7891011'],
'has_access_to_raw_data': True, 'lab_person': {
'affiliation': 'knight lab', 'name': 'LabDude',
'email': 'lab_dude@foo.bar'},
'principal_investigator': {
'affiliation': 'Wash U', 'name': 'PIDude',
'email': 'PI_dude@foo.bar'},
'study_alias': 'Cannabis Soils', 'study_id': 1,
'most_recent_contact': datetime(2014, 5, 19, 16, 11),
'publication_doi': ['10.100/123456', '10.100/7891011'],
'publication_pid': ['123456', '7891011'],
'num_samples': 27,
'study_title': 'Identification of the Microbiomes for '
'Cannabis Soils',
'number_samples_collected': 27,
'owner': 'test@foo.bar',
'ebi_submission_status': 'submitted',
'has_access_to_raw_data': True,
'show_biom_download_button': True,
'show_raw_download_button': True,
'ebi_study_accession': 'EBI123456-BB'},
'ebi_study_accession': 'EBI123456-BB', 'num_samples': 27,
'study_title': (
'Identification of the Microbiomes for Cannabis Soils'),
'number_samples_collected': 27},
'message': '',
'editable': True}
self.assertEqual(obs, exp)

Expand Down Expand Up @@ -139,6 +129,8 @@ def test_study_get_req(self):
'study_description': 'DESC',
'shared_with': [],
'lab_person': None,
'study_alias': "FCM",
'owner': 'Dude',
'principal_investigator': {'affiliation': 'Wash U',
'name': 'PIDude',
'email': 'PI_dude@foo.bar'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def setUp(self):

self.single_exp = {
'study_id': 1,
'owner': 'Dude',
'study_alias': 'Cannabis Soils',
'status': 'private',
'study_abstract':
'This is a preliminary study to examine the microbiota '
Expand Down Expand Up @@ -113,8 +115,8 @@ def test_build_study_info_empty_study(self):
'study_alias': 'alias',
'study_abstract': 'abstract'}
Study.create(User('test@foo.bar'), "My study", info=info)
obs = _build_study_info(User('test@foo.bar'), 'user')

obs = _build_study_info(User('test@foo.bar'), 'user')
self.exp.append({
'metadata_complete': False,
'ebi_submission_status':
Expand All @@ -126,6 +128,8 @@ def test_build_study_info_empty_study(self):
'publication_doi': [],
'study_abstract': 'abstract',
'study_id': 2,
'owner': 'Dude',
'study_alias': 'alias',
'ebi_study_accession': None,
'study_title': 'My study',
'study_tags': None,
Expand Down Expand Up @@ -260,6 +264,8 @@ def setUp(self):
'metadata_complete': True,
'ebi_submission_status': 'submitted',
'study_id': 1,
'study_alias': 'Cannabis Soils',
'owner': 'Dude',
'ebi_study_accession': 'EBI123456-BB',
'shared': ('<a target="_blank" href="mailto:shared@foo.bar">'
'Shared</a>'),
Expand Down
4 changes: 2 additions & 2 deletions qiita_pet/support_files/doc/source/tutorials/sharing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ permissions that the owner of the Study has. These permissions are:
Sharing a Study
---------------

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

.. figure:: images/sharing_study.gif
:align: center

Analysis sharing example
16 changes: 10 additions & 6 deletions qiita_pet/templates/list_studies.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@
{ "data": "pi" },
{ "data": "pubs" },
{ "data": "status" },
{ "data": "ebi_info" }
],
{ "data": "ebi_info" },
{ "data": "study_alias" }],
columnDefs: [
{type:'natural', targets:[2,6,7]},
{"targets": [ 2 ], "visible": false},
{"targets": [ 2, 10 ], "visible": false},
// render zero
{"render": function ( data, type, row, meta ) {
if (data !== null && data !== undefined && data.length != 0){
Expand Down Expand Up @@ -166,7 +166,10 @@
{"render": function ( data, type, row, meta ) {
var glyph = 'remove';
if(data === true) { glyph = 'ok' }
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>";
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/>";
result += "<b>Owner:</b> " + row.owner + "</br>";
result += "<span id='shared_html_"+ row.study_id +"'>"+ data +"</span>";
return result;
}, targets: [5]},
],
"language": {
Expand Down Expand Up @@ -408,7 +411,7 @@ <h5 class="gray-msg">
</h5>
<select class="js-select2-multiple form-control" id="study_tags_multiple" multiple="multiple" style="width: 100%"></select>

<h3 class="gray-msg">Your Studies (includes shared with you)</h3>
<h3 class="gray-msg">Your Studies</h3>
<table id="user-studies-table" class="table table-bordered gray-msg">
<thead>
<tr>
Expand All @@ -422,10 +425,11 @@ <h3 class="gray-msg">Your Studies (includes shared with you)</h3>
<th>Publications</th>
<th>Status</th>
<th>Qiita EBI submission</th>
<th>Study Alias</th>
</tr>
</thead>
</table>
<h3 class="gray-msg">Other Studies</h3>
<h3 class="gray-msg">Public Studies</h3>
<table id="studies-table" class="table table-bordered gray-msg">
<thead>
<tr>
Expand Down