-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make help email address configurable instead of hard coding #3384
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
57d1b14
Update CHANGELOG.md
antgonza 13eafdf
fix CHANGELOG.md CONFLICT
antgonza 55f2a6b
make help email address configurable instead of hard coding
sjanssen2 cae7fc7
codestyle
sjanssen2 fd0e9f7
don't default with email addresses but raise Errors
sjanssen2 4cc57ae
set mail addresses in example configuration, which is also used for
sjanssen2 b2eb8f0
addessing Antonios issues + switch to a non deprecated read fct.
sjanssen2 daddfc2
updating dummy help email address in tests
sjanssen2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 == '[email protected]') and \ | ||
(self.test_environment is False): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! Good idea! |
||
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 == '[email protected]') 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( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = [email protected] | ||
|
||
# The email address, Qiita sends internal notifications to a sys admin | ||
SYSADMIN_EMAIL = [email protected] | ||
|
||
# ----------------------------- SMTP settings ----------------------------- | ||
[smtp] | ||
# The hostname to connect to | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, '[email protected]') | ||
self.assertEqual(obs.sysadmin_email, '[email protected]') | ||
|
||
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 [email protected] | ||
self.conf.set('main', 'HELP_EMAIL', '') | ||
with self.assertRaises(ValueError): | ||
obs._get_main(self.conf) | ||
|
||
# test if it falls back to [email protected] | ||
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 = [email protected] | ||
|
||
# The email address, Qiita sends internal notifications to a sys admin | ||
SYSADMIN_EMAIL = [email protected] | ||
|
||
# ----------------------------- SMTP settings ----------------------------- | ||
[smtp] | ||
# The hostname to connect to | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,7 +493,7 @@ def resource_allocation_info(self): | |
samples, columns, input_size = self.shape | ||
parts = [] | ||
error_msg = ('Obvious incorrect allocation. Please ' | ||
'contact [email protected]') | ||
'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( | ||
'[email protected]', msg['subject'], | ||
qiita_config.sysadmin_email, msg['subject'], | ||
msg['message']) | ||
|
||
sql = """UPDATE qiita.processing_job | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = '[email protected]' | ||
email_to = qiita_config.help_email | ||
subject = ('QIITA: Artifact %s awaiting_approval. Study %d, ' | ||
'Prep %d' % (artifact_id, sid, | ||
artifact.prep_templates[0].id)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <a href='mailto:qiita.help" | ||
"@gmail.com'>[email protected]</a>") | ||
"qiita developers at <a href='mailto:%s'>%s</a>") % ( | ||
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): | |
"<p>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 <a " | ||
"href=\"mailto:[email protected]\">[email protected]" | ||
"</a>.</p>") | ||
"href=\"mailto:%s\">%s" | ||
"</a>.</p>") % (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.<br/>If a verification email" | ||
" has not arrived in 15 minutes, please email <a href='" | ||
"mailto:[email protected]'>[email protected]</a>") | ||
"mailto:%s'>%s</a>") % (qiita_config.help_email, | ||
qiita_config.help_email) | ||
except QiitaDBUnknownIDError: | ||
msg = "Unknown user" | ||
except RuntimeError: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: ' | ||
'[email protected]') | ||
'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: ' | ||
'[email protected]') | ||
'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: ' | ||
'[email protected]') | ||
'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: ' | ||
'[email protected]') | ||
'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: ' | ||
'[email protected]') | ||
'%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: ' | ||
'[email protected]') | ||
'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: ' | ||
'[email protected]') | ||
'this is a mistake contact: %s' % | ||
qiita_config.help_email) | ||
else: | ||
self._write_nginx_file_list(to_download) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ' | ||
'[email protected]' % 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,7 +191,7 @@ | |
$inp.attr('type', 'file'); | ||
} | ||
else { | ||
bootstrapAlert("Error: Parameter type (" + p_type + ") not recognized. Please, take a screenshot and <a href='mailto:[email protected]'>contact us</a>", "danger"); | ||
bootstrapAlert("Error: Parameter type (" + p_type + ") not recognized. Please, take a screenshot and <a href='mailto:{% raw qiita_config.portal_dir %}'>contact us</a>", "danger"); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<h1 style="text-align:center">ERROR: CODE {{status_code}}!</h1> | ||
<h2 style="text-align:center">{% raw escape(error) %}</h2> | ||
<p style="text-align:center">The error has been logged and will be looked at.</p> | ||
<p style="text-align:center">Need help? Send us an <a href="mailto:[email protected]">email</a>.</p> | ||
<p style="text-align:center">Need help? Send us an <a href="mailto:{% raw qiita_config.help_email %}">email</a>.</p> | ||
{% if is_admin %} | ||
<p style="text-align:center">Go to the <a href="{% raw qiita_config.portal_dir %}/admin/error/">error page</a> to view the logs</p> | ||
{% end %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,7 @@ | |
message.append(' '+data[level]); | ||
// prepend the "Need help" message | ||
if (level == 'warning' || level == 'danger'){ | ||
message.append('<p style="text-align:center">Need help? Send us an <a href="mailto:[email protected]">email</a>.</p>'); | ||
message.append('<p style="text-align:center">Need help? Send us an <a href="mailto:{% raw qiita_config.portal_dir %}">email</a>.</p>'); | ||
} | ||
analyses_all_messages.prepend(message); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,7 +163,7 @@ | |
.fail(function(response, status, error) { | ||
var text = 'The query response is larger than is currently allowed, please try another. <a href="https://github.com/biocore/qiita/issues/2312" target="_blank">Track progress on this issue.</a>'; | ||
if (response.status != 504) { | ||
text = 'Status code: "' + response.status + '" - ' + error + '.<br/>Please send a screenshot to <a href="[email protected]">[email protected]</a>.'; | ||
text = 'Status code: "' + response.status + '" - ' + error + '.<br/>Please send a screenshot to <a href="mailto:{% raw qiita_config.portal_dir %}">{% raw qiita_config.portal_dir %}</a>.'; | ||
} | ||
redbiom_info.html( | ||
`<div class="alert alert-danger alert-dismissible" role="alert"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -588,7 +588,7 @@ <h4 class="modal-title">File really big.</h4> | |
<div id="footer" style="font-size: 12px; text-align: center; z-index: 1000;"> | ||
Thank you for using Qiita. <a target="_blank" href="{% raw qiita_config.portal_dir %}/static/doc/html/faq.html#how-to-cite-qiita">Citing Qiita?</a>. | ||
<br/> | ||
Questions? <a href="mailto:[email protected]">[email protected]</a>; don't forget to add your study or analysis id. | ||
Questions? <a href="mailto:{% raw qiita_config.help_email %}">{% raw qiita_config.help_email %}</a>; don't forget to add your study or analysis id. | ||
<br/> | ||
Read our <a href="{% raw qiita_config.portal_dir %}/iframe/?iframe=qiita-terms">terms and conditions</a>. | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,7 +159,7 @@ | |
<input id="studyTags"> | ||
<small> | ||
New tags are linked to the user that created them. | ||
Report <a href="mailto:[email protected]">abuse</a>. | ||
Report <a href="mailto:{% raw qiita_config.help_email %}">abuse</a>. | ||
</small> | ||
<br/> | ||
<button type="submit" class="btn btn-default" onclick="tags_patch(); return false;">Save tags</button> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change this to something like: