Skip to content

Commit 9021ae3

Browse files
committed
Merge pull request #1142 from josenavas/disable-make-processed-data-public
Disable make processed data private
2 parents 2246242 + 919bd88 commit 9021ae3

File tree

12 files changed

+106
-27
lines changed

12 files changed

+106
-27
lines changed

qiita_db/metadata_template/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
from .sample_template import SampleTemplate
1010
from .prep_template import PrepTemplate
1111
from .util import load_template_to_dataframe
12-
from .constants import TARGET_GENE_DATA_TYPES
12+
from .constants import (TARGET_GENE_DATA_TYPES, SAMPLE_TEMPLATE_COLUMNS,
13+
PREP_TEMPLATE_COLUMNS,
14+
PREP_TEMPLATE_COLUMNS_TARGET_GENE)
1315

1416

1517
__all__ = ['SampleTemplate', 'PrepTemplate', 'load_template_to_dataframe',
16-
'TARGET_GENE_DATA_TYPES']
18+
'TARGET_GENE_DATA_TYPES', 'SAMPLE_TEMPLATE_COLUMNS',
19+
'PREP_TEMPLATE_COLUMNS', 'PREP_TEMPLATE_COLUMNS_TARGET_GENE']

qiita_db/metadata_template/test/test_prep_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
get_count)
3333
from qiita_db.metadata_template.prep_template import PrepTemplate, PrepSample
3434
from qiita_db.metadata_template.sample_template import SampleTemplate, Sample
35-
from qiita_db.metadata_template.constants import (
36-
PREP_TEMPLATE_COLUMNS, PREP_TEMPLATE_COLUMNS_TARGET_GENE)
35+
from qiita_db.metadata_template import (PREP_TEMPLATE_COLUMNS,
36+
PREP_TEMPLATE_COLUMNS_TARGET_GENE)
3737

3838

3939
class BaseTestPrepSample(TestCase):

qiita_pet/handlers/study_handlers/description_handlers.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
from qiita_db.data import RawData, PreprocessedData, ProcessedData
2323
from qiita_db.ontology import Ontology
2424
from qiita_db.metadata_template import (PrepTemplate, SampleTemplate,
25-
load_template_to_dataframe)
25+
load_template_to_dataframe,
26+
SAMPLE_TEMPLATE_COLUMNS)
2627
from qiita_db.util import convert_to_id, get_mountpoint
2728
from qiita_db.exceptions import (QiitaDBUnknownIDError, QiitaDBColumnError,
2829
QiitaDBExecutionError, QiitaDBDuplicateError,
@@ -624,6 +625,18 @@ def display_template(self, study, user, msg, msg_level, full_access,
624625
user_level = user.level
625626
sample_template_exists = SampleTemplate.exists(study.id)
626627

628+
if sample_template_exists:
629+
st = SampleTemplate(study.id)
630+
missing_cols = st.check_restrictions(
631+
[SAMPLE_TEMPLATE_COLUMNS['qiita_main']])
632+
allow_approval = len(missing_cols) == 0
633+
approval_deny_msg = (
634+
"Processed data approval request is disabled due to missing "
635+
"columns in the sample template: %s" % ', '.join(missing_cols))
636+
else:
637+
allow_approval = False
638+
approval_deny_msg = ""
639+
627640
# The general information of the study can be changed if the study is
628641
# not public or if the user is an admin, in which case they can always
629642
# modify the information of the study
@@ -638,6 +651,8 @@ def display_template(self, study, user, msg, msg_level, full_access,
638651
show_edit_btn=show_edit_btn,
639652
show_data_tabs=sample_template_exists,
640653
full_access=full_access,
654+
allow_approval=allow_approval,
655+
approval_deny_msg=approval_deny_msg,
641656
top_tab=top_tab,
642657
sub_tab=sub_tab,
643658
prep_tab=prep_tab)

qiita_pet/handlers/study_handlers/ebi_handlers.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from qiita_ware.demux import stats as demux_stats
1414
from qiita_ware.dispatchable import submit_to_ebi
1515
from qiita_db.data import PreprocessedData
16-
from qiita_db.metadata_template import PrepTemplate, SampleTemplate
16+
from qiita_db.metadata_template import (PrepTemplate, SampleTemplate,
17+
SAMPLE_TEMPLATE_COLUMNS,
18+
PREP_TEMPLATE_COLUMNS)
1719
from qiita_db.study import Study
1820
from qiita_db.exceptions import QiitaDBUnknownIDError
1921
from qiita_pet.handlers.base_handlers import BaseHandler
@@ -58,11 +60,33 @@ def display_template(self, preprocessed_data_id, msg, msg_level):
5860
stats.append(('Number of sequences', demux_file_stats.n))
5961
msg_level = 'success'
6062

63+
# Check if the templates have all the required columns for EBI
64+
pt_missing_cols = prep_template.check_restrictions(
65+
[PREP_TEMPLATE_COLUMNS['EBI']])
66+
st_missing_cols = sample_template.check_restrictions(
67+
[SAMPLE_TEMPLATE_COLUMNS['EBI']])
68+
allow_submission = (len(pt_missing_cols) == 0 and
69+
len(st_missing_cols) == 0)
70+
71+
if not allow_submission:
72+
msg_list = ["Submission to EBI disabled due to missing columns:"]
73+
if len(pt_missing_cols) > 0:
74+
msg_list.append("Columns missing in prep template: %s"
75+
% ', '.join(pt_missing_cols))
76+
if len(st_missing_cols) > 0:
77+
msg_list.append("Columns missing in sample template: %s"
78+
% ', '.join(st_missing_cols))
79+
ebi_disabled_msg = "<br/>".join(msg_list)
80+
else:
81+
ebi_disabled_msg = None
82+
6183
self.render('ebi_submission.html',
6284
study_title=study.title, stats=stats, message=msg,
6385
study_id=study.id, level=msg_level,
6486
preprocessed_data_id=preprocessed_data_id,
65-
investigation_type=prep_template.investigation_type)
87+
investigation_type=prep_template.investigation_type,
88+
allow_submission=allow_submission,
89+
ebi_disabled_msg=ebi_disabled_msg)
6690

6791
@authenticated
6892
def get(self, preprocessed_data_id):

qiita_pet/templates/ebi_submission.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ <h1>Submission summary for study: <b>{{study_title}}</b></h1>
2828
<br/><br/>
2929
{% if investigation_type %}
3030
{% if level != 'danger' and maintenance is None %}
31-
<br/>
32-
What kind of submission do you want to do?
33-
<select name="submission_type">
34-
<option value="ADD">ADD</option>
35-
<option value="MODIFY">MODIFY</option>
36-
</select>
37-
<br/><br/>
38-
<input type="submit" class="btn btn-primary" value="Submit to EBI">
31+
{% if allow_submission %}
32+
<br/>
33+
What kind of submission do you want to do?
34+
<select name="submission_type">
35+
<option value="ADD">ADD</option>
36+
<option value="MODIFY">MODIFY</option>
37+
</select>
38+
<br/><br/>
39+
<input type="submit" class="btn btn-primary" value="Submit to EBI">
40+
{% else %}
41+
<b>{% raw ebi_disabled_msg %}
42+
{% end %}
3943
{% end %}
4044
{% else %}
4145
<b>You need to set an investigation type to continue!</b>

qiita_pet/templates/study_description.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ <h2><i>{{study_alias}}</i></h2>
607607
<!-- Show the preprocessed data tab -->
608608
{% module PreprocessedDataTab(study, full_access) %}
609609
<!-- Show the processed data tab -->
610-
{% module ProcessedDataTab(study, full_access) %}
610+
{% module ProcessedDataTab(study, full_access, allow_approval, approval_deny_msg) %}
611611
{% end %}
612612
</div>
613613

qiita_pet/templates/study_description_templates/prep_template_panel.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ <h4 class="panel-title">
8888
<br/>
8989
{% if not preprocessed_data or preprocessing_status.startswith('failed') %}
9090
{% if study_status == 'sandbox' %}
91-
<a class="btn btn-primary glyphicon glyphicon-play" data-toggle="modal" data-target="#preprocess-modal-view-{{prep_id}}" style="word-spacing: -10px;"> Preprocess</a>
91+
{% if show_preprocess_btn %}
92+
<a class="btn btn-primary glyphicon glyphicon-play" data-toggle="modal" data-target="#preprocess-modal-view-{{prep_id}}" style="word-spacing: -10px;"> Preprocess</a>
93+
{% else %}
94+
<b>{{ no_preprocess_msg }}</b>
95+
{% end %}
9296
{% end %}
9397
<br>
9498
<i>Status:</i> {{preprocessing_status}}

qiita_pet/templates/study_description_templates/processed_data_info_tab.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
{% end %}
1616
</table>
1717
{% if btn_to_show == 'request_approval' %}
18-
<a class="btn btn-default glyphicon glyphicon-eye-open" onClick="request_approval({{pd_id}});" style="word-spacing: -10px;"> Request making this data private</a>
18+
{% if allow_approval %}
19+
<a class="btn btn-default glyphicon glyphicon-eye-open" onClick="request_approval({{pd_id}});" style="word-spacing: -10px;"> Request making this data private</a>
20+
{% else %}
21+
<b>{{ approval_deny_msg }}</b>
22+
{% end %}
1923
{% elif btn_to_show == 'approve' %}
2024
<a class="btn btn-success glyphicon glyphicon-thumbs-up" onClick="approve_study({{pd_id}});" style="word-spacing: -10px;"> Approve this data to be private</a>
2125
{% elif btn_to_show == 'make_public' %}

qiita_pet/templates/study_description_templates/processed_data_tab.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</div>
2424
<!-- Create one tab pane for each processed data -->
2525
{% for pd_id, pd, _ in available_processed_data %}
26-
{% module ProcessedDataInfoTab(study_id, pd) %}
26+
{% module ProcessedDataInfoTab(study_id, pd, allow_approval, approval_deny_msg) %}
2727
{% end %}
2828
</div>
2929
{% else %}

qiita_pet/templates/study_description_templates/raw_data_editor_tab.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h4>Add prep template to this raw data</h4>
7373
<h4>Prep templates uploaded</h4>
7474
<div class="panel-group" id="prep-accordion-{{raw_data_id}}">
7575
{% for prep in available_prep_templates %}
76-
{% module PrepTemplatePanel(prep, study_id, is_editable, ena_terms, study_status, user_defined_terms) %}
76+
{% module PrepTemplatePanel(prep, study_id, is_editable, ena_terms, study_status, user_defined_terms, raw_data_files) %}
7777
{% end %}
7878
</div>
7979
</td>

0 commit comments

Comments
 (0)