Skip to content
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

fix #3326 #3328

Merged
merged 3 commits into from
Nov 16, 2023
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
10 changes: 4 additions & 6 deletions qiita_pet/handlers/study_handlers/sample_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def sample_template_overview_handler_get_request(study_id, user):
# Specific information if it exists or not:
data_types = []
st_fp_id = None
old_files = []
st_files = []
num_samples = 0
num_cols = 0
columns = []
Expand All @@ -369,11 +369,9 @@ def sample_template_overview_handler_get_request(study_id, user):
# the list of old filepaths
st = SampleTemplate(study_id)
all_st_files = st.get_filepaths()
# The current sample template file is the first one in the list
# (pop(0)) and we are interested only in the id ([0])
st_fp_id = all_st_files.pop(0)[0]
st_fp_id = all_st_files[0][0]
# For the old filepaths we are only interested in their basename
old_files = [basename(fp) for _, fp in all_st_files]
st_files = [basename(fp) for _, fp in all_st_files]
# The number of samples - this is a space efficient way of counting
# the number of samples. Doing len(list(st.keys())) creates a list
# that we are not using
Expand All @@ -393,7 +391,7 @@ def sample_template_overview_handler_get_request(study_id, user):
'user_can_edit': Study(study_id).can_edit(user),
'job': job,
'download_id': st_fp_id,
'old_files': old_files,
'st_files': st_files,
'num_samples': num_samples,
'num_columns': num_cols,
'columns': columns,
Expand Down
12 changes: 9 additions & 3 deletions qiita_pet/handlers/study_handlers/tests/test_sample_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def test_sample_template_overview_handler_get_request(self):
'user_can_edit': True,
'job': None,
'download_id': 23,
'old_files': ['1_19700101-000000.txt'],
'st_files': ['1_19700101-000000.txt'],
'num_samples': 27,
'num_columns': 31,
'columns': sorted(
Expand All @@ -297,6 +297,9 @@ def test_sample_template_overview_handler_get_request(self):
'host_subject_id', 'description', 'latitude',
'longitude', 'scientific_name', 'env_package']),
'sample_restrictions': ''}
# the first element is the current fp and the name is based on the
# last update so just removing to easy test
obs['st_files'].pop(0)
self.assertEqual(obs, exp)

# Test sample template doesn't exist
Expand All @@ -312,7 +315,7 @@ def test_sample_template_overview_handler_get_request(self):
'user_can_edit': True,
'job': None,
'download_id': None,
'old_files': [],
'st_files': [],
'num_samples': 0,
'num_columns': 0,
'columns': [],
Expand Down Expand Up @@ -494,7 +497,7 @@ def test_get(self):
'user_can_edit': True,
'job': None,
'download_id': 23,
'old_files': ['1_19700101-000000.txt'],
'st_files': ['1_19700101-000000.txt'],
'num_samples': 27,
'num_columns': 31,
'columns': sorted(
Expand All @@ -510,6 +513,9 @@ def test_get(self):
'host_subject_id', 'description', 'latitude',
'longitude', 'scientific_name', 'env_package']),
'sample_restrictions': ''}
# the first element is the current fp and the name is based on the
# last update so just removing to easy test
obs['st_files'].pop(0)
self.assertDictEqual(obs, exp)


Expand Down
5 changes: 4 additions & 1 deletion qiita_pet/static/js/sampleTemplateVue.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Vue.component('sample-template-page', {
'<div class="row">' +
'<div class="col-md-12">' +
'<h3>Sample Information<span id="title-h3"></span></h3>' +
'<h6>Last update: <span id="current-sample-info"></span></h6>' +
'</div>' +
'</div>' +
// Processing div
Expand Down Expand Up @@ -376,6 +377,7 @@ Vue.component('sample-template-page', {

// Add the buttons next to the title
// Download Sample Information button
$('#current-sample-info').append(vm.current_file.split('_')[1].split('.')[0]);
$('#title-h3').append(' ');
$btn = $('<a>').addClass('btn btn-default').attr('href', vm.portal + '/download/' + vm.downloadId).appendTo('#title-h3');
$('<span>').addClass('glyphicon glyphicon-download-alt').appendTo($btn);
Expand Down Expand Up @@ -575,7 +577,8 @@ Vue.component('sample-template-page', {
vm.userCanEdit = data['user_can_edit'];
vm.job = data['job'];
vm.downloadId = data['download_id'];
vm.oldFiles = data['old_files'];
vm.current_file = data['st_files'][0];
vm.oldFiles = data['st_files'].slice(1);
vm.numSamples = data['num_samples'];
vm.numColumns = data['num_columns'];
vm.columns = data['columns'];
Expand Down
5 changes: 4 additions & 1 deletion qiita_pet/templates/study_ajax/prep_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@
<!-- Prep template title and buttons -->
<div class="row">
<div class="col-md-12">
{% if other_filepaths is not None %}
<h6>Last update: {{ other_filepaths[0].split('_')[-1] }}</h6>
{% end %}
<h4>
{% if deprecated %}
<span class="label label-danger">This Preparation Information has been DEPRECATED</span>
Expand Down Expand Up @@ -558,7 +561,7 @@ <h5>
{% end %}
<div id="other-filepaths" class="collapse">
<small>
{% raw '<br/>'.join(other_filepaths) %}
{% raw '<br/>'.join(other_filepaths[1:]) %}
</small>
</div>
<div id="prep-artifact-summary-div" class="tab-pane fade in active">
Expand Down
Loading