Skip to content

Commit 10a69d8

Browse files
committed
Addressing more comments
1 parent 94ca93e commit 10a69d8

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

qiita_pet/templates/study_description_templates/prep_template_info_tab.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ <h4 class="panel-title">
126126
<div id="files-{{pt_id}}-0" class="filesgroup"></div>
127127
{% for _, value, filepath_types in filetypes %}
128128
<div id="files-{{pt_id}}-{{value}}" class="filesgroup">
129-
<table border="0">
130-
<tr><td><b>Choose the files to link to the raw data</b></td></tr>
129+
<br/>
130+
<b>Choose the files to link to the raw data</b>
131+
<br/>
132+
<table class="table table-striped">
131133
<tr>
132134
<th>File</th>
133135
<th>&nbsp;&nbsp;&nbsp;</th>
@@ -147,8 +149,8 @@ <h4 class="panel-title">
147149
</td>
148150
</tr>
149151
{% end %}
150-
<tr><td><a class="btn btn-primary" onclick="create_raw_data({{pt_id}}, {{value}});">Add</a></td></tr>
151152
</table>
153+
<a class="btn btn-primary" onclick="create_raw_data({{pt_id}}, {{value}});">Link</a>
152154
</div>
153155
{% end %}
154156
</div>

qiita_pet/uimodules/prep_template_tab.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
FASTQ=['barcodes', 'forward seqs', 'reverse seqs'])
3535

3636

37-
def get_accessible_raw_data(user):
37+
def _get_accessible_raw_data(user):
3838
"""Retrieves a tuple of raw_data_id and the last study title for that
3939
raw_data
4040
"""
@@ -45,34 +45,35 @@ def get_accessible_raw_data(user):
4545
return d
4646

4747

48-
def get_raw_data(rdis):
49-
"""Get all raw data objects from a list of raw_data_ids"""
50-
return [RawData(rdi) for rdi in rdis]
51-
52-
53-
def get_prep_templates(pt_ids):
54-
"""Get all the prep template objects from a list of ids
48+
def _template_generator(study, full_access):
49+
"""Generates tuples of prep template information
5550
5651
Parameters
5752
----------
58-
pt_ids : list of int
59-
The prep template ids
53+
study : Study
54+
The study to get all the prep templates
55+
full_access : boolean
56+
A boolean that indicates if the user has full access to the study
6057
6158
Returns
6259
-------
63-
list of PrepTemplate
60+
Generator of tuples of (int, str, PrepTemplate, (str, str, str))
61+
Each tuple contains the prep template id, the prep template data_type
62+
the PrepTemplate object and a tuple with 3 strings for the style of
63+
the prep template status icons
6464
"""
65-
return [PrepTemplate(pt_id) for pt_id in sorted(pt_ids)]
65+
for pt_id in study.prep_templates():
66+
pt = PrepTemplate(pt_id)
67+
if full_access or pt.status() == 'public':
68+
yield (pt.id, pt.data_type(), pt, STATUS_STYLER[pt.status])
6669

6770

6871
class PrepTemplateTab(BaseUIModule):
6972
def render(self, study, full_access):
7073
files = [f for _, f in get_files_from_uploads_folders(str(study.id))]
7174
data_types = sorted(viewitems(get_data_types()), key=itemgetter(1))
7275
prep_templates_info = [
73-
(pt.id, pt.data_type(), pt, STATUS_STYLER[pt.status])
74-
for pt in get_prep_templates(study.prep_templates())
75-
if full_access or pt.status() == 'public']
76+
res for res in _template_generator(study, full_access)]
7677
# Get all the ENA terms for the investigation type
7778
ontology = Ontology(convert_to_id('ENA', 'ontology'))
7879
# make "Other" show at the bottom of the drop down menu
@@ -143,9 +144,9 @@ def render(self, study, prep_template, full_access, ena_terms,
143144
files = [f for _, f in get_files_from_uploads_folders(str(study.id))]
144145

145146
other_studies_rd = sorted(viewitems(
146-
get_accessible_raw_data(user)))
147+
_get_accessible_raw_data(user)))
147148

148-
# A prep template can be modified if it's status is sanbdox
149+
# A prep template can be modified if its status is sanbdox
149150
is_editable = prep_template.status == 'sanbdox'
150151

151152
raw_data_id = prep_template.raw_data

0 commit comments

Comments
 (0)