diff --git a/Pipfile b/Pipfile index 55a3ef1..41cc583 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ django-filter = "*" python-dotenv = "*" django-compressor = "*" django-debug-toolbar = "*" +django-anymail = {extras = ["mailgun"], version = "*"} [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index deaca44..f588f99 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "87374a4c3741836c76d7a6aebe57dd8f1375eebf323b210aab0139c6d45b2266" + "sha256": "5ea894435847d40e57233d8d25545677108e62ef14c57bd53ef5640c88784881" }, "pipfile-spec": 6, "requires": { @@ -24,13 +24,40 @@ "markers": "python_version >= '3.7'", "version": "==3.5.2" }, + "certifi": { + "hashes": [ + "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d", + "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412" + ], + "markers": "python_version >= '3.6'", + "version": "==2022.6.15" + }, + "charset-normalizer": { + "hashes": [ + "sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5", + "sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413" + ], + "markers": "python_version >= '3.6'", + "version": "==2.1.0" + }, "django": { "hashes": [ - "sha256:502ae42b6ab1b612c933fb50d5ff850facf858a4c212f76946ecd8ea5b3bf2d9", - "sha256:f7431a5de7277966f3785557c3928433347d998c1e6459324501378a291e5aab" + "sha256:031ccb717782f6af83a0063a1957686e87cb4581ea61b47b3e9addf60687989a", + "sha256:032f8a6fc7cf05ccd1214e4a2e21dfcd6a23b9d575c6573cacc8c67828dbe642" ], "index": "pypi", - "version": "==4.0.5" + "version": "==4.1" + }, + "django-anymail": { + "extras": [ + "mailgun" + ], + "hashes": [ + "sha256:49d83d7c16316ca86a624097496881d59b7d71b16bf1c5211cffa5b19ef98d0c", + "sha256:783342d49dd07d68778b81dd12a94c86e1d217463a68a85450a0513fabe31345" + ], + "index": "pypi", + "version": "==8.6" }, "django-appconf": { "hashes": [ @@ -64,6 +91,14 @@ "index": "pypi", "version": "==22.1" }, + "idna": { + "hashes": [ + "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff", + "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" + ], + "markers": "python_version >= '3.5'", + "version": "==3.3" + }, "python-dotenv": { "hashes": [ "sha256:b7e3b04a59693c42c36f9ab1cc2acc46fa5df8c78e178fc33a8d4cd05c8d498f", @@ -97,6 +132,14 @@ ], "version": "==1.1.0" }, + "requests": { + "hashes": [ + "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983", + "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349" + ], + "markers": "python_version >= '3.7' and python_version < '4'", + "version": "==2.28.1" + }, "rjsmin": { "hashes": [ "sha256:05efa485dfddb6418e3b86d8862463aa15641a61f6ae05e7e6de8f116ee77c69", @@ -129,6 +172,14 @@ ], "markers": "python_version >= '3.5'", "version": "==0.4.2" + }, + "urllib3": { + "hashes": [ + "sha256:c33ccba33c819596124764c23a97d25f32b28433ba0dedeb77d873a38722c9bc", + "sha256:ea6e8fb210b19d950fab93b60c9009226c63a28808bc8386e05301e25883ac0a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' and python_version < '4'", + "version": "==1.26.11" } }, "develop": {} diff --git a/src/indici/config.py b/src/indici/config.py index 211a768..12e2335 100644 --- a/src/indici/config.py +++ b/src/indici/config.py @@ -1,5 +1,5 @@ -from dotenv import load_dotenv import os +from dotenv import load_dotenv load_dotenv() @@ -18,3 +18,23 @@ CACHE_CONFIG = { 'location': os.environ.get('CACHE_LOCATION', ''), 'backend': os.environ.get('CACHE_BACKEND', ''), } + +STATIC_ROOT_PATH = os.environ.get('STATIC_ROOT_PATH', '/var/www/indici/static/') +LOGGING_FILE_LOCATION = os.environ.get('LOGGING_FILE_LOCATION', '/home/nathanchapman/debug.log') + +ANYMAIL_CONFIG = { + 'MAILGUN_API_KEY': os.environ.get('MAILGUN_API_KEY', ''), + 'MAILGUN_SENDER_DOMAIN': os.environ.get('MAILGUN_SENDER_DOMAIN', '') +} + +DEFAULT_FROM_EMAIL = os.environ.get( + 'DEFAULT_FROM_EMAIL', 'notifications@indici.windmillapps.org' +) +SERVER_EMAIL = os.environ.get('SERVER_EMAIL', 'server@indici.windmillapps.org') +ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL', 'debug@nathanjchapman.com') + +SECURE_HSTS_SECONDS = os.environ.get('SECURE_HSTS_SECONDS', 3600) +SECURE_SSL_REDIRECT = os.environ.get('SECURE_SSL_REDIRECT', 'False') == 'True' +SESSION_COOKIE_SECURE = os.environ.get('SESSION_COOKIE_SECURE', 'False') == 'True' +CSRF_COOKIE_SECURE = os.environ.get('CSRF_COOKIE_SECURE', 'False') == 'True' +SECURE_CROSS_ORIGIN_OPENER_POLICY = 'same-origin-allow-popups' diff --git a/src/indici/settings.py b/src/indici/settings.py index fb74c2a..a5a5c06 100644 --- a/src/indici/settings.py +++ b/src/indici/settings.py @@ -8,7 +8,12 @@ from .config import * BASE_DIR = Path(__file__).resolve().parent.parent # Add Your Required Allow Host -ALLOWED_HOSTS = [] +if not DEBUG: + ALLOWED_HOSTS = [ + 'forum.windmillapps.org', + ] +else: + ALLOWED_HOSTS = ['192.168.68.106', '127.0.0.1', 'localhost'] INTERNAL_IPS = [ '127.0.0.1', @@ -30,6 +35,7 @@ INSTALLED_APPS = [ 'debug_toolbar', 'django_filters', 'compressor', + 'anymail', # Local 'accounts.apps.AccountsConfig', @@ -146,6 +152,16 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' AUTH_USER_MODEL = 'accounts.User' LOGIN_REDIRECT_URL = reverse_lazy('core:home') + +# Email +ANYMAIL = ANYMAIL_CONFIG +EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend' +ADMINS = ( + ('Nathan Chapman', ADMIN_EMAIL), +) + +MANAGERS = ADMINS + # Decimal settings DEFAULT_DECIMAL_PLACES = 2 DEFAULT_MAX_DIGITS = 12