Skip to content

Commit

Permalink
refactor: Update email settings in settings_env.py for logging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoleoncio committed Oct 17, 2024
1 parent 15f68fe commit 299d1e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wikiscore/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from contests.locale import get_available_languages
from wikiscore.settings_env import (
BASE_DIR, HOME, SECRET_KEY, SOCIAL_AUTH_MEDIAWIKI_URL, SOCIAL_AUTH_MEDIAWIKI_KEY,
SOCIAL_AUTH_MEDIAWIKI_SECRET, DEBUG, ALLOWED_HOSTS, SOCIAL_AUTH_MEDIAWIKI_CALLBACK, DATABASES
SOCIAL_AUTH_MEDIAWIKI_SECRET, DEBUG, ALLOWED_HOSTS, SOCIAL_AUTH_MEDIAWIKI_CALLBACK, DATABASES,
EMAIL_HOST, EMAIL_PORT, SERVER_EMAIL, ADMINS
)

# Secrets
Expand Down
16 changes: 16 additions & 0 deletions wikiscore/settings_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def configure_settings():
hosts = [ os.environ.get("TOOLNAME") + '.toolforge.org', 'toolforge.org' ]
callback = 'https://' + os.environ.get("TOOLNAME") + '.toolforge.org/oauth/complete/mediawiki/'
message = 'You are running in production mode'
email_host = 'mail.tools.wmflabs.org'
email_port = 587
server_email = os.environ.get("TOOLNAME") + '@tools.wmflabs.org'
admins = [('Admin', '[email protected]')]

databases = {
'default': {
Expand All @@ -42,6 +46,10 @@ def configure_settings():
hosts = ['127.0.0.1']
callback = 'http://127.0.0.1:8000/oauth/complete/mediawiki/'
message = 'You are running in local mode, please make sure to set up the replica.my.cnf file to run in production mode'
email_host = 'localhost'
email_port = 25
server_email = 'root@localhost'
admins = []

databases = {
'default': {
Expand All @@ -56,11 +64,19 @@ def configure_settings():
'SOCIAL_AUTH_MEDIAWIKI_CALLBACK': callback,
'DATABASES': databases,
'MESSAGE': message,
'EMAIL_HOST': email_host,
'EMAIL_PORT': email_port,
'SERVER_EMAIL': server_email,
'ADMINS': admins
}

settings = configure_settings()
DEBUG = settings['DEBUG']
ALLOWED_HOSTS = settings['ALLOWED_HOSTS']
SOCIAL_AUTH_MEDIAWIKI_CALLBACK = settings['SOCIAL_AUTH_MEDIAWIKI_CALLBACK']
DATABASES = settings['DATABASES']
EMAIL_HOST = settings['EMAIL_HOST']
EMAIL_PORT = settings['EMAIL_PORT']
SERVER_EMAIL = settings['SERVER_EMAIL']
ADMINS = settings['ADMINS']
print(settings['MESSAGE'])

0 comments on commit 299d1e3

Please sign in to comment.