diff --git a/qiita_core/configuration_manager.py b/qiita_core/configuration_manager.py index 4c26583d9..44db36400 100644 --- a/qiita_core/configuration_manager.py +++ b/qiita_core/configuration_manager.py @@ -117,6 +117,10 @@ class ConfigurationManager(object): The script used to start the plugins plugin_dir : str The path to the directory containing the plugin configuration files + help_email : str + The email address a user should write to when asking for help + sysadmin_email : str + The email address, Qiita sends internal notifications to a sys admin Raises ------ @@ -234,6 +238,32 @@ def _get_main(self, config): self.key_file = join(install_dir, 'qiita_core', 'support_files', 'ci_server.key') + self.help_email = config.get('main', 'HELP_EMAIL') + if not self.help_email: + raise ValueError( + "You did not specify the HELP_EMAIL address in the main " + "section of Qiita's config file. This address is essential " + "for users to ask for help as it is displayed at various " + "location throughout Qiita's web pages.") + if (self.help_email == 'foo@bar.com') and \ + (self.test_environment is False): + warnings.warn( + "Using the github fake email for HELP_EMAIL, " + "are you sure this is OK?") + + self.sysadmin_email = config.get('main', 'SYSADMIN_EMAIL') + if not self.sysadmin_email: + raise ValueError( + "You did not specify the SYSADMIN_EMAIL address in the main " + "section of Qiita's config file. Serious issues will " + "automatically be reported to a sys admin, an according " + "address is therefore required!") + if (self.sysadmin_email == 'jeff@bar.com') and \ + (self.test_environment is False): + warnings.warn( + "Using the github fake email for SYSADMIN_EMAIL, " + "are you sure this is OK?") + def _get_job_scheduler(self, config): """Get the configuration of the job_scheduler section""" self.job_scheduler_owner = config.get( diff --git a/qiita_core/support_files/config_test.cfg b/qiita_core/support_files/config_test.cfg index e6423f609..8f922e34e 100644 --- a/qiita_core/support_files/config_test.cfg +++ b/qiita_core/support_files/config_test.cfg @@ -68,6 +68,12 @@ COOKIE_SECRET = SECRET # The value used to secure JWTs for delegated permission artifact download. JWT_SECRET = SUPER_SECRET +# Address a user should write to when asking for help +HELP_EMAIL = foo@bar.com + +# The email address, Qiita sends internal notifications to a sys admin +SYSADMIN_EMAIL = jeff@bar.com + # ----------------------------- SMTP settings ----------------------------- [smtp] # The hostname to connect to diff --git a/qiita_core/tests/test_configuration_manager.py b/qiita_core/tests/test_configuration_manager.py index 2a60f353b..ebc7f67f1 100644 --- a/qiita_core/tests/test_configuration_manager.py +++ b/qiita_core/tests/test_configuration_manager.py @@ -29,7 +29,7 @@ def setUp(self): self.conf = ConfigParser() with open(self.conf_fp, newline=None) as f: - self.conf.readfp(f) + self.conf.read_file(f) def tearDown(self): if self.old_conf_fp is not None: @@ -132,6 +132,8 @@ def test_get_main(self): # Warning raised if No files will be allowed to be uploaded # Warning raised if no cookie_secret + self.conf.set('main', 'HELP_EMAIL', 'ignore@me') + self.conf.set('main', 'SYSADMIN_EMAIL', 'ignore@me') with warnings.catch_warnings(record=True) as warns: obs._get_main(self.conf) @@ -180,6 +182,35 @@ def test_get_main(self): self.assertEqual(obs.qiita_env, "") + def test_help_email(self): + obs = ConfigurationManager() + + with warnings.catch_warnings(record=True) as warns: + # warning get only issued when in non test environment + self.conf.set('main', 'TEST_ENVIRONMENT', 'FALSE') + + obs._get_main(self.conf) + self.assertEqual(obs.help_email, 'foo@bar.com') + self.assertEqual(obs.sysadmin_email, 'jeff@bar.com') + + obs_warns = [str(w.message) for w in warns] + exp_warns = [ + 'Using the github fake email for HELP_EMAIL, ' + 'are you sure this is OK?', + 'Using the github fake email for SYSADMIN_EMAIL, ' + 'are you sure this is OK?'] + self.assertCountEqual(obs_warns, exp_warns) + + # test if it falls back to qiita.help@gmail.com + self.conf.set('main', 'HELP_EMAIL', '') + with self.assertRaises(ValueError): + obs._get_main(self.conf) + + # test if it falls back to qiita.help@gmail.com + self.conf.set('main', 'SYSADMIN_EMAIL', '') + with self.assertRaises(ValueError): + obs._get_main(self.conf) + def test_get_job_scheduler(self): obs = ConfigurationManager() @@ -274,6 +305,12 @@ def test_get_portal(self): # The value used to secure JWTs for delegated permission artifact download. JWT_SECRET = SUPER_SECRET +# Address a user should write to when asking for help +HELP_EMAIL = foo@bar.com + +# The email address, Qiita sends internal notifications to a sys admin +SYSADMIN_EMAIL = jeff@bar.com + # ----------------------------- SMTP settings ----------------------------- [smtp] # The hostname to connect to diff --git a/qiita_db/processing_job.py b/qiita_db/processing_job.py index a1f7e5baa..11145925b 100644 --- a/qiita_db/processing_job.py +++ b/qiita_db/processing_job.py @@ -493,7 +493,7 @@ def resource_allocation_info(self): samples, columns, input_size = self.shape parts = [] error_msg = ('Obvious incorrect allocation. Please ' - 'contact qiita.help@gmail.com') + 'contact %s' % qiita_config.help_email) for part in allocation.split('--'): param = '' if part.startswith('time '): @@ -902,7 +902,7 @@ def _set_status(self, value, error_msg=None): if self.user.level in {'admin', 'wet-lab admin'}: if value == 'error': qdb.util.send_email( - 'jdereus@health.ucsd.edu', msg['subject'], + qiita_config.sysadmin_email, msg['subject'], msg['message']) sql = """UPDATE qiita.processing_job diff --git a/qiita_pet/handlers/artifact_handlers/base_handlers.py b/qiita_pet/handlers/artifact_handlers/base_handlers.py index ca60051cb..bdeae6eaf 100644 --- a/qiita_pet/handlers/artifact_handlers/base_handlers.py +++ b/qiita_pet/handlers/artifact_handlers/base_handlers.py @@ -370,7 +370,7 @@ def artifact_patch_request(user, artifact_id, req_op, req_path, req_value=None, sid = artifact.study.id if artifact.visibility == 'awaiting_approval': - email_to = 'qiita.help@gmail.com' + email_to = qiita_config.help_email subject = ('QIITA: Artifact %s awaiting_approval. Study %d, ' 'Prep %d' % (artifact_id, sid, artifact.prep_templates[0].id)) diff --git a/qiita_pet/handlers/auth_handlers.py b/qiita_pet/handlers/auth_handlers.py index 38759e77f..4c5e306b1 100644 --- a/qiita_pet/handlers/auth_handlers.py +++ b/qiita_pet/handlers/auth_handlers.py @@ -62,8 +62,8 @@ def post(self): url_escape(username), url)) except Exception: msg = ("Unable to send verification email. Please contact the " - "qiita developers at qiita.help@gmail.com") + "qiita developers at %s") % ( + qiita_config.help_email, qiita_config.help_email) self.redirect(u"%s/?level=danger&message=%s" % (qiita_config.portal_dir, url_escape(msg))) return @@ -75,8 +75,9 @@ def post(self): "

If you don't receive your activation email within a " "couple of minutes, check your spam folder. If you still " "don't see it, send us an email at qiita.help@gmail.com" - ".

") + "href=\"mailto:%s\">%s" + ".

") % (qiita_config.help_email, + qiita_config.help_email) self.redirect(u"%s/?level=success&message=%s" % (qiita_config.portal_dir, url_escape(msg))) else: @@ -135,7 +136,8 @@ def post(self): "the verify link. You may need to check your spam " "folder to find the email.
If a verification email" " has not arrived in 15 minutes, please email qiita.help@gmail.com") + "mailto:%s'>%s") % (qiita_config.help_email, + qiita_config.help_email) except QiitaDBUnknownIDError: msg = "Unknown user" except RuntimeError: diff --git a/qiita_pet/handlers/download.py b/qiita_pet/handlers/download.py index 93c81d4c0..bf0242773 100644 --- a/qiita_pet/handlers/download.py +++ b/qiita_pet/handlers/download.py @@ -445,12 +445,12 @@ def get(self): public_raw_download = study.public_raw_download if study.status != 'public': raise HTTPError(404, reason='Study is not public. If this ' - 'is a mistake contact: ' - 'qiita.help@gmail.com') + 'is a mistake contact: %s' % + qiita_config.help_email) elif data == 'raw' and not public_raw_download: raise HTTPError(422, reason='No raw data access. If this ' - 'is a mistake contact: ' - 'qiita.help@gmail.com') + 'is a mistake contact: %s' + % qiita_config.help_email) else: # raw data artifacts = [a for a in study.artifacts(dtype=data_type) @@ -466,8 +466,8 @@ def get(self): if not to_download: raise HTTPError(422, reason='Nothing to download. If ' - 'this is a mistake contact: ' - 'qiita.help@gmail.com') + 'this is a mistake contact: %s' + % qiita_config.help_email) else: self._write_nginx_file_list(to_download) @@ -496,18 +496,18 @@ def get(self): else: if artifact.visibility != 'public': raise HTTPError(404, reason='Artifact is not public. If ' - 'this is a mistake contact: ' - 'qiita.help@gmail.com') + 'this is a mistake contact: %s' + % qiita_config.help_email) elif artifact.has_human: raise HTTPError(404, reason='Artifact has possible human ' 'sequences. If this is a mistake contact: ' - 'qiita.help@gmail.com') + '%s' % qiita_config.help_email) else: to_download = self._list_artifact_files_nginx(artifact) if not to_download: raise HTTPError(422, reason='Nothing to download. If ' - 'this is a mistake contact: ' - 'qiita.help@gmail.com') + 'this is a mistake contact: %s' + % qiita_config.help_email) else: self._write_nginx_file_list(to_download) @@ -600,8 +600,8 @@ def get(self, jti): to_download = self._list_artifact_files_nginx(artifact) if not to_download: raise HTTPError(422, reason='Nothing to download. If ' - 'this is a mistake contact: ' - 'qiita.help@gmail.com') + 'this is a mistake contact: %s' % + qiita_config.help_email) else: self._write_nginx_file_list(to_download) diff --git a/qiita_pet/handlers/study_handlers/sample_template.py b/qiita_pet/handlers/study_handlers/sample_template.py index 0e44ace76..2c3373f87 100644 --- a/qiita_pet/handlers/study_handlers/sample_template.py +++ b/qiita_pet/handlers/study_handlers/sample_template.py @@ -12,7 +12,7 @@ from tornado.web import authenticated, HTTPError -from qiita_core.qiita_settings import r_client +from qiita_core.qiita_settings import r_client, qiita_config from qiita_pet.handlers.util import to_int from qiita_pet.handlers.base_handlers import BaseHandler from qiita_db.util import get_files_from_uploads_folders @@ -214,8 +214,8 @@ def sample_template_handler_patch_request(user, req_op, req_path, # the system filepath = req_value if not exists(filepath): - reason = ('Upload file not found (%s), please report to ' - 'qiita.help@gmail.com' % filepath) + reason = ('Upload file not found (%s), please report to %s' + % (filepath, qiita_config.help_email)) raise HTTPError(404, reason=reason) else: # Check if the file exists diff --git a/qiita_pet/templates/admin_processing_job.html b/qiita_pet/templates/admin_processing_job.html index d341294d4..6f9b81acc 100644 --- a/qiita_pet/templates/admin_processing_job.html +++ b/qiita_pet/templates/admin_processing_job.html @@ -191,7 +191,7 @@ $inp.attr('type', 'file'); } else { - bootstrapAlert("Error: Parameter type (" + p_type + ") not recognized. Please, take a screenshot and contact us", "danger"); + bootstrapAlert("Error: Parameter type (" + p_type + ") not recognized. Please, take a screenshot and contact us", "danger"); } } diff --git a/qiita_pet/templates/error.html b/qiita_pet/templates/error.html index dbd51f70c..b79141735 100644 --- a/qiita_pet/templates/error.html +++ b/qiita_pet/templates/error.html @@ -3,7 +3,7 @@

ERROR: CODE {{status_code}}!

{% raw escape(error) %}

The error has been logged and will be looked at.

-

Need help? Send us an email.

+

Need help? Send us an email.

{% if is_admin %}

Go to the error page to view the logs

{% end %} diff --git a/qiita_pet/templates/list_analyses.html b/qiita_pet/templates/list_analyses.html index 0e890b210..bcfc79207 100644 --- a/qiita_pet/templates/list_analyses.html +++ b/qiita_pet/templates/list_analyses.html @@ -121,7 +121,7 @@ message.append(' '+data[level]); // prepend the "Need help" message if (level == 'warning' || level == 'danger'){ - message.append('

Need help? Send us an email.

'); + message.append('

Need help? Send us an email.

'); } analyses_all_messages.prepend(message); } diff --git a/qiita_pet/templates/redbiom.html b/qiita_pet/templates/redbiom.html index 9c0414568..5f2c31cf8 100644 --- a/qiita_pet/templates/redbiom.html +++ b/qiita_pet/templates/redbiom.html @@ -163,7 +163,7 @@ .fail(function(response, status, error) { var text = 'The query response is larger than is currently allowed, please try another. Track progress on this issue.'; if (response.status != 504) { - text = 'Status code: "' + response.status + '" - ' + error + '.
Please send a screenshot to qiita.help@gmail.com.'; + text = 'Status code: "' + response.status + '" - ' + error + '.
Please send a screenshot to {% raw qiita_config.portal_dir %}.'; } redbiom_info.html( `