diff --git a/Pipfile b/Pipfile index 36be345..8a5a5a0 100644 --- a/Pipfile +++ b/Pipfile @@ -5,6 +5,7 @@ name = "pypi" [packages] django = "*" +django-anymail = {extras = ["mailgun"], version = "*"} [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 4395777..88bca9a 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "c36ae28fea7b9a4cc02145632e2f41469af2e7b38b801903abb8333d3306f36b" + "sha256": "88b6a9fdda6471bfc16c42a906945bb034d4b2d576f31179a72471296eac58cd" }, "pipfile-spec": 6, "requires": { @@ -24,6 +24,21 @@ "markers": "python_version >= '3.6'", "version": "==3.4.1" }, + "certifi": { + "hashes": [ + "sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee", + "sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8" + ], + "version": "==2021.5.30" + }, + "charset-normalizer": { + "hashes": [ + "sha256:88fce3fa5b1a84fdcb3f603d889f723d1dd89b26059d0123ca435570e848d5e1", + "sha256:c46c3ace2d744cfbdebceaa3c19ae691f53ae621b39fd7570f59d14fb7f2fd12" + ], + "markers": "python_version >= '3'", + "version": "==2.0.3" + }, "django": { "hashes": [ "sha256:3da05fea54fdec2315b54a563d5b59f3b4e2b1e69c3a5841dda35019c01855cd", @@ -32,6 +47,25 @@ "index": "pypi", "version": "==3.2.5" }, + "django-anymail": { + "extras": [ + "mailgun" + ], + "hashes": [ + "sha256:2e8307e84f0a12f9283469017094a8246db9a0fc608ac17dd1027ee011ece986", + "sha256:671a338de43b8e414d48c6d16aac1df54d2f24f916e1073f9f60aef5acffaf89" + ], + "index": "pypi", + "version": "==8.4" + }, + "idna": { + "hashes": [ + "sha256:14475042e284991034cb48e06f6851428fb14c4dc953acd9be9a5e95c7b6dd7a", + "sha256:467fbad99067910785144ce333826c71fb0e63a425657295239737f7ecd125f3" + ], + "markers": "python_version >= '3'", + "version": "==3.2" + }, "pytz": { "hashes": [ "sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da", @@ -39,6 +73,14 @@ ], "version": "==2021.1" }, + "requests": { + "hashes": [ + "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24", + "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", + "version": "==2.26.0" + }, "sqlparse": { "hashes": [ "sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0", @@ -46,6 +88,14 @@ ], "markers": "python_version >= '3.5'", "version": "==0.4.1" + }, + "urllib3": { + "hashes": [ + "sha256:39fb8672126159acb139a7718dd10806104dec1e2f0f6c88aab05d17df10c8d4", + "sha256:f57b4c16c62fa2760b7e3d97c35b255512fb6b59a259730f36ba32ce9f8e342f" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", + "version": "==1.26.6" } }, "develop": {} diff --git a/onboard/settings.py b/onboard/settings.py index 87a4c6c..f168f1c 100644 --- a/onboard/settings.py +++ b/onboard/settings.py @@ -10,6 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -20,12 +21,13 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-fdq1(f%l*__obb*zvb3gqnlki!ryr@_1_5om(_2ju3mu70mi4%' +with open('/etc/secret_key.txt') as f: + SECRET_KEY = f.read().strip() # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False' -ALLOWED_HOSTS = ['localhost', 'xcarbon.lan'] +ALLOWED_HOSTS = ['onboard.windmillapps.org', '127.0.0.1'] # Application definition @@ -122,6 +124,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.2/howto/static-files/ STATIC_URL = '/static/' +STATIC_ROOT = BASE_DIR / 'static' STATICFILES_DIRS = [BASE_DIR / 'static'] @@ -132,3 +135,44 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' # Site ID SITE_ID = 1 + + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'file': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'filename': '/var/log/django-onboard/debug.log', + }, + }, + 'loggers': { + 'django': { + 'handlers': ['file'], + 'level': 'DEBUG', + 'propagate': True, + }, + }, +} + +# Email +ANYMAIL = { + "MAILGUN_API_KEY": os.environ.get('MAILGUN_API_KEY'), +} + +SERVER_EMAIL = 'noreply@onboard.windmillapps.org' +DEFAULT_FROM_EMAIL = 'noreply@onboard.windmillapps.org' + +ADMINS = ( + ('Nathan Chapman', 'debug@nathanjchapman.com'), +) +MANAGERS = ADMINS + +EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND') + + +SECURE_HSTS_SECONDS = os.environ.get('DJANGO_SECURE_HSTS_SECONDS', '') != 'False' +SECURE_SSL_REDIRECT = os.environ.get('DJANGO_SECURE_SSL_REDIRECT', '') != 'False' +SESSION_COOKIE_SECURE = os.environ.get('DJANGO_SESSION_COOKIE_SECURE', '') != 'False' +CSRF_COOKIE_SECURE = os.environ.get('DJANGO_CSRF_COOKIE_SECURE', '') != 'False' \ No newline at end of file