Skip to content

Commit

Permalink
Merge branch 'main' into issue-679-add-language-basics
Browse files Browse the repository at this point in the history
  • Loading branch information
geekygirlsarah authored Oct 26, 2023
2 parents f4f04b3 + c4b4f97 commit b0d60d1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
38 changes: 34 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 All @@ -55,7 +53,8 @@
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware'
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.common.BrokenLinkEmailsMiddleware'
]

ROOT_URLCONF = 'codethesaurus.urls'
Expand Down Expand Up @@ -147,5 +146,36 @@
os.path.join(BASE_DIR, 'static'),
]

# For server error reporting
# 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', '')
SERVER_EMAIL = os.getenv('SERVER_EMAIL', '')
EMAIL_USE_SSL = os.getenv('EMAIL_USE_SSL', '')
EMAIL_PORT = os.getenv('EMAIL_PORT', '')
EMAIL_USE_TLS = os.getenv('EMAIL_USE_TLS', '')

LOGGING = {
"version": 1, # the dictConfig format version
"disable_existing_loggers": False, # retain the default loggers
"handlers": {
"mail_admins": {
"level": "ERROR",
"class": "django.utils.log.AdminEmailHandler",
"include_html": True,
},
}
}

# Configure Django App for Heroku.
django_on_heroku.settings(locals(), test_runner=False, databases=False, staticfiles=True, logging=True)
3 changes: 2 additions & 1 deletion web/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def __init__(self):
meta_info_json = json.load(meta_file)
self.structures = meta_info_json["structures"]
self.languages = meta_info_json["languages"]


def language_name(self, language_key):
"""
Expand Down Expand Up @@ -281,7 +282,7 @@ def load_languages(self, language_keys_versions, meta_structure):
raise MissingStructureError(
meta_structure,
language_key,
self.language_friendly_name(language_key),
self.language_name(language_key),
version,
) from file_not_found
except KeyError as key_error:
Expand Down

0 comments on commit b0d60d1

Please sign in to comment.