Skip to content

Commit

Permalink
Extracting env vars for email and web url
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Dec 20, 2022
1 parent 7ac5101 commit 6e74716
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions core/common/utils.py
Expand Up @@ -546,6 +546,9 @@ def jsonify_safe(value):


def web_url():
url = settings.WEB_URL
if url:
return url
env = settings.ENV
if not env or env in ['development', 'ci']:
return 'http://localhost:4000'
Expand Down
24 changes: 15 additions & 9 deletions core/settings.py
Expand Up @@ -395,15 +395,21 @@
# Serving swagger static files (inserted after SecurityMiddleware)
MIDDLEWARE.insert(1, 'whitenoise.middleware.WhiteNoiseMiddleware')

if not ENV or ENV in ['production']:
EMAIL_SUBJECT_PREFIX = '[Openconceptlab.org] '
else:
EMAIL_SUBJECT_PREFIX = f'[Openconceptlab.org] [{ENV.upper()}]'

if not ENV or ENV in ['development', 'ci']:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
else:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_SUBJECT_PREFIX = os.environ.get('EMAIL_SUBJECT_PREFIX', None)
if not EMAIL_SUBJECT_PREFIX:
if not ENV or ENV in ['production']:
EMAIL_SUBJECT_PREFIX = '[Openconceptlab.org] '
else:
EMAIL_SUBJECT_PREFIX = f'[Openconceptlab.org] [{ENV.upper()}]'

EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', None)
if not EMAIL_BACKEND:
if not ENV or ENV in ['development', 'ci']:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
else:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

WEB_URL = os.environ.get('WEB_URL', None)

VERSION = __version__

Expand Down

0 comments on commit 6e74716

Please sign in to comment.