Skip to content

Commit

Permalink
Add parser for ADMINS env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
geekygirlsarah committed Oct 23, 2023
1 parent 3628bc3 commit 7df54d8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions codethesaurus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os
import dj_database_url
import django_on_heroku


# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand All @@ -33,7 +31,7 @@
# redirect all http requests to https in non debugging envs
SECURE_SSL_REDIRECT = not DEBUG

ALLOWED_HOSTS = [ "*" ]
ALLOWED_HOSTS = ["*"]

# Application definition

Expand Down Expand Up @@ -149,7 +147,16 @@
]

# For server error reporting
ADMINS = os.getenv('ADMINS', '')
# Admin emails are stored like Name1:[email protected],Name2:[email protected],...
# Parse that first then set the rest
ADMIN_STRING = os.getenv('ADMINS', '')
ADMIN_SPLIT = ADMIN_STRING.split(",") # gives us name/value list
ADMINS = []
for item in ADMIN_SPLIT:
if item == "":
break
contact = item.split(":")
ADMINS.append((contact[0], contact[1]))
EMAIL_HOST = os.getenv('EMAIL_HOST', '')
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', '')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', '')
Expand Down

0 comments on commit 7df54d8

Please sign in to comment.