Skip to content

add is_from_analysis to artifact_handlers #2293

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
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
2 changes: 2 additions & 0 deletions qiita_pet/handlers/artifact_handlers/base_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def artifact_summary_get_request(user, artifact_id):
'buttons': str,
'processing_parameters': dict of {str: object},
'files': list of (int, str),
'is_from_analysis': bool,
'processing_jobs': list of [str, str, str, str, str],
'summary': str or None,
'job': [str, str, str],
Expand Down Expand Up @@ -212,6 +213,7 @@ def artifact_summary_get_request(user, artifact_id):
'buttons': ' '.join(buttons),
'processing_parameters': processing_parameters,
'files': files,
'is_from_analysis': artifact.analysis is not None,
'processing_jobs': processing_jobs,
'summary': summary,
'job': job_info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_artifact_summary_get_request(self):
'sandbox</button>'),
'processing_parameters': {},
'files': exp_files,
'is_from_analysis': False,
'summary': None,
'job': None,
'processing_jobs': exp_p_jobs,
Expand Down Expand Up @@ -136,6 +137,7 @@ def test_artifact_summary_get_request(self):
'sandbox</button>'),
'processing_parameters': {},
'files': exp_files,
'is_from_analysis': False,
'summary': None,
'job': [job.id, 'queued', None],
'processing_jobs': exp_p_jobs,
Expand Down Expand Up @@ -173,6 +175,7 @@ def test_artifact_summary_get_request(self):
'sandbox</button>'),
'processing_parameters': {},
'files': exp_files,
'is_from_analysis': False,
'summary': exp_summary_path,
'job': None,
'processing_jobs': exp_p_jobs,
Expand All @@ -196,6 +199,7 @@ def test_artifact_summary_get_request(self):
'buttons': '',
'processing_parameters': {},
'files': [],
'is_from_analysis': False,
'summary': exp_summary_path,
'job': None,
'processing_jobs': exp_p_jobs,
Expand Down Expand Up @@ -244,6 +248,7 @@ def test_artifact_summary_get_request(self):
'min_per_read_length_fraction': 0.75,
'barcode_type': u'golay_12'},
'files': exp_files,
'is_from_analysis': False,
'summary': None,
'job': None,
'processing_jobs': exp_p_jobs,
Expand All @@ -262,6 +267,7 @@ def test_artifact_summary_get_request(self):
'buttons': '',
'processing_parameters': {},
'files': [(27, 'biom_table.biom (biom)')],
'is_from_analysis': True,
'summary': None,
'job': None,
'processing_jobs': [],
Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/templates/artifact_ajax/artifact_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h4>
<i id='summary-title'>{{name}}</i><i> (ID: {{artifact_id}}) Visibility: {{visibility}}</i>
{% if editable %}
<a class="btn btn-default btn-sm" data-toggle="modal" data-target="#update-artifact-name"><span class="glyphicon glyphicon-pencil"></span> Edit</a>
{% if artifact_type == 'BIOM' %}
{% if artifact_type == 'BIOM' and not is_from_analysis %}
<input type="button" class="btn btn-default btn-sm" value="Add to Analysis" onclick="send_samples_to_analysis(this, [{{artifact_id}}]);">
{% else %}
<a class="btn btn-default btn-sm" onclick="load_process_artifact_ui({{artifact_id}});"><span class="glyphicon glyphicon-play"></span> Process</a>
Expand Down
18 changes: 11 additions & 7 deletions qiita_pet/test/test_qiita_redbiom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# -----------------------------------------------------------------------------

from unittest import main

from copy import deepcopy
from json import loads

from qiita_pet.test.tornado_test_base import TestHandlerBase
Expand All @@ -26,14 +26,18 @@ def test_post_metadata(self):
}
response = self.post('/redbiom/', post_args)
self.assertEqual(response.code, 200)
data = DATA

samples = ['1.SKD6.640190', '1.SKD9.640182', '1.SKD8.640184',
'1.SKD5.640186', '1.SKD2.640178', '1.SKD4.640185',
'1.SKD1.640179', '1.SKD3.640198', '1.SKD7.640191']
data[0]['artifact_biom_ids'] = {
exp_artifact_biom_ids = {
'5': samples, '4': samples, '7': samples, '6': samples}
exp = {'status': 'success', 'message': '', 'data': data}
self.assertEqual(loads(response.body), exp)
response_body = loads(response.body)
obs_artifact_biom_ids = response_body['data'][0].pop(
'artifact_biom_ids')
self.assertItemsEqual(obs_artifact_biom_ids, exp_artifact_biom_ids)
exp = {'status': 'success', 'message': '', 'data': DATA}
self.assertEqual(response_body, exp)

post_args = {
'search': 'inf',
Expand Down Expand Up @@ -62,7 +66,7 @@ def test_post_features(self):
'search_on': 'feature'
}
response = self.post('/redbiom/', post_args)
data = DATA
data = deepcopy(DATA)
data[0]['artifact_biom_ids'] = {
'5': ['1.SKM3.640197'], '4': ['1.SKM3.640197']}
exp = {'status': 'success', 'message': '', 'data': data}
Expand All @@ -84,7 +88,7 @@ def test_post_taxon(self):
'search': 'o__0319-7L14',
'search_on': 'taxon'
}
data = DATA
data = deepcopy(DATA)
data[0]['artifact_biom_ids'] = {
'5': ['1.SKM3.640197'], '4': ['1.SKM3.640197']}
response = self.post('/redbiom/', post_args)
Expand Down