diff --git a/qiita_db/metadata_template/__init__.py b/qiita_db/metadata_template/__init__.py
index 632f1acd8..ece9a5ff0 100644
--- a/qiita_db/metadata_template/__init__.py
+++ b/qiita_db/metadata_template/__init__.py
@@ -9,8 +9,11 @@
from .sample_template import SampleTemplate
from .prep_template import PrepTemplate
from .util import load_template_to_dataframe
-from .constants import TARGET_GENE_DATA_TYPES
+from .constants import (TARGET_GENE_DATA_TYPES, SAMPLE_TEMPLATE_COLUMNS,
+ PREP_TEMPLATE_COLUMNS,
+ PREP_TEMPLATE_COLUMNS_TARGET_GENE)
__all__ = ['SampleTemplate', 'PrepTemplate', 'load_template_to_dataframe',
- 'TARGET_GENE_DATA_TYPES']
+ 'TARGET_GENE_DATA_TYPES', 'SAMPLE_TEMPLATE_COLUMNS',
+ 'PREP_TEMPLATE_COLUMNS', 'PREP_TEMPLATE_COLUMNS_TARGET_GENE']
diff --git a/qiita_db/metadata_template/test/test_prep_template.py b/qiita_db/metadata_template/test/test_prep_template.py
index 49a29087c..bd940f34f 100644
--- a/qiita_db/metadata_template/test/test_prep_template.py
+++ b/qiita_db/metadata_template/test/test_prep_template.py
@@ -32,8 +32,8 @@
get_count)
from qiita_db.metadata_template.prep_template import PrepTemplate, PrepSample
from qiita_db.metadata_template.sample_template import SampleTemplate, Sample
-from qiita_db.metadata_template.constants import (
- PREP_TEMPLATE_COLUMNS, PREP_TEMPLATE_COLUMNS_TARGET_GENE)
+from qiita_db.metadata_template import (PREP_TEMPLATE_COLUMNS,
+ PREP_TEMPLATE_COLUMNS_TARGET_GENE)
class BaseTestPrepSample(TestCase):
diff --git a/qiita_pet/handlers/study_handlers/description_handlers.py b/qiita_pet/handlers/study_handlers/description_handlers.py
index 0f68c63e8..f63901c18 100644
--- a/qiita_pet/handlers/study_handlers/description_handlers.py
+++ b/qiita_pet/handlers/study_handlers/description_handlers.py
@@ -22,7 +22,8 @@
from qiita_db.data import RawData, PreprocessedData, ProcessedData
from qiita_db.ontology import Ontology
from qiita_db.metadata_template import (PrepTemplate, SampleTemplate,
- load_template_to_dataframe)
+ load_template_to_dataframe,
+ SAMPLE_TEMPLATE_COLUMNS)
from qiita_db.util import convert_to_id, get_mountpoint
from qiita_db.exceptions import (QiitaDBUnknownIDError, QiitaDBColumnError,
QiitaDBExecutionError, QiitaDBDuplicateError,
@@ -624,6 +625,18 @@ def display_template(self, study, user, msg, msg_level, full_access,
user_level = user.level
sample_template_exists = SampleTemplate.exists(study.id)
+ if sample_template_exists:
+ st = SampleTemplate(study.id)
+ missing_cols = st.check_restrictions(
+ [SAMPLE_TEMPLATE_COLUMNS['qiita_main']])
+ allow_approval = len(missing_cols) == 0
+ approval_deny_msg = (
+ "Processed data approval request is disabled due to missing "
+ "columns in the sample template: %s" % ', '.join(missing_cols))
+ else:
+ allow_approval = False
+ approval_deny_msg = ""
+
# The general information of the study can be changed if the study is
# not public or if the user is an admin, in which case they can always
# modify the information of the study
@@ -638,6 +651,8 @@ def display_template(self, study, user, msg, msg_level, full_access,
show_edit_btn=show_edit_btn,
show_data_tabs=sample_template_exists,
full_access=full_access,
+ allow_approval=allow_approval,
+ approval_deny_msg=approval_deny_msg,
top_tab=top_tab,
sub_tab=sub_tab,
prep_tab=prep_tab)
diff --git a/qiita_pet/handlers/study_handlers/ebi_handlers.py b/qiita_pet/handlers/study_handlers/ebi_handlers.py
index 637121031..3e7a6f795 100644
--- a/qiita_pet/handlers/study_handlers/ebi_handlers.py
+++ b/qiita_pet/handlers/study_handlers/ebi_handlers.py
@@ -13,7 +13,9 @@
from qiita_ware.demux import stats as demux_stats
from qiita_ware.dispatchable import submit_to_ebi
from qiita_db.data import PreprocessedData
-from qiita_db.metadata_template import PrepTemplate, SampleTemplate
+from qiita_db.metadata_template import (PrepTemplate, SampleTemplate,
+ SAMPLE_TEMPLATE_COLUMNS,
+ PREP_TEMPLATE_COLUMNS)
from qiita_db.study import Study
from qiita_db.exceptions import QiitaDBUnknownIDError
from qiita_pet.handlers.base_handlers import BaseHandler
@@ -58,11 +60,33 @@ def display_template(self, preprocessed_data_id, msg, msg_level):
stats.append(('Number of sequences', demux_file_stats.n))
msg_level = 'success'
+ # Check if the templates have all the required columns for EBI
+ pt_missing_cols = prep_template.check_restrictions(
+ [PREP_TEMPLATE_COLUMNS['EBI']])
+ st_missing_cols = sample_template.check_restrictions(
+ [SAMPLE_TEMPLATE_COLUMNS['EBI']])
+ allow_submission = (len(pt_missing_cols) == 0 and
+ len(st_missing_cols) == 0)
+
+ if not allow_submission:
+ msg_list = ["Submission to EBI disabled due to missing columns:"]
+ if len(pt_missing_cols) > 0:
+ msg_list.append("Columns missing in prep template: %s"
+ % ', '.join(pt_missing_cols))
+ if len(st_missing_cols) > 0:
+ msg_list.append("Columns missing in sample template: %s"
+ % ', '.join(st_missing_cols))
+ ebi_disabled_msg = "
".join(msg_list)
+ else:
+ ebi_disabled_msg = None
+
self.render('ebi_submission.html',
study_title=study.title, stats=stats, message=msg,
study_id=study.id, level=msg_level,
preprocessed_data_id=preprocessed_data_id,
- investigation_type=prep_template.investigation_type)
+ investigation_type=prep_template.investigation_type,
+ allow_submission=allow_submission,
+ ebi_disabled_msg=ebi_disabled_msg)
@authenticated
def get(self, preprocessed_data_id):
diff --git a/qiita_pet/templates/ebi_submission.html b/qiita_pet/templates/ebi_submission.html
index e46501822..4a1c8221d 100644
--- a/qiita_pet/templates/ebi_submission.html
+++ b/qiita_pet/templates/ebi_submission.html
@@ -28,14 +28,18 @@