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.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 + '.