-
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 1 commit
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 |
---|---|---|
|
@@ -119,10 +119,8 @@ class ConfigurationManager(object): | |
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 | ||
Defaults to [email protected] | ||
sysadmin_email : str | ||
The email address, Qiita sends internal notifications to a sys admin | ||
Defaults to [email protected] | ||
|
||
Raises | ||
------ | ||
|
@@ -247,6 +245,11 @@ def _get_main(self, config): | |
"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): | ||
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: | ||
|
@@ -255,6 +258,11 @@ def _get_main(self, config): | |
"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""" | ||
|
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 |
---|---|---|
|
@@ -69,10 +69,10 @@ COOKIE_SECRET = SECRET | |
JWT_SECRET = SUPER_SECRET | ||
|
||
# Address a user should write to when asking for help | ||
HELP_EMAIL = qiita.help@gmail.com | ||
HELP_EMAIL = foo@bar.com | ||
|
||
# The email address, Qiita sends internal notifications to a sys admin | ||
SYSADMIN_EMAIL = [email protected] | ||
SYSADMIN_EMAIL = [email protected] | ||
|
||
# ----------------------------- SMTP settings ----------------------------- | ||
[smtp] | ||
|
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) | ||
|
||
|
@@ -183,9 +185,21 @@ def test_get_main(self): | |
def test_help_email(self): | ||
obs = ConfigurationManager() | ||
|
||
obs._get_main(self.conf) | ||
self.assertEqual(obs.help_email, '[email protected]') | ||
self.assertEqual(obs.sysadmin_email, '[email protected]') | ||
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', '') | ||
|
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.
Nice! Good idea!