diff --git a/marietje/manage.py b/marietje/manage.py index c3b939e..029aed6 100755 --- a/marietje/manage.py +++ b/marietje/manage.py @@ -3,7 +3,13 @@ import os import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "marietje.settings.settings") + try: + import marietje.settings.production # noqa + except ModuleNotFoundError: + # Use the development settings if the production settings are not available (so we're on a dev machine) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "marietje.settings.development") + else: + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "marietje.settings.production") try: from django.core.management import execute_from_command_line except ImportError: diff --git a/marietje/marietje/settings/settings.py b/marietje/marietje/settings/base.py similarity index 85% rename from marietje/marietje/settings/settings.py rename to marietje/marietje/settings/base.py index 4fc3125..b055549 100644 --- a/marietje/marietje/settings/settings.py +++ b/marietje/marietje/settings/base.py @@ -1,14 +1,7 @@ -""" -Django settings for marietje project. -""" - import os +from pathlib import Path -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -SECRET_KEY = 'sae2hahHao1soo0Ocoz5Ieh1Ushae6feJe4mooliooj0Ula8' -DEBUG = False -ALLOWED_HOSTS = ['*'] +BASE_DIR = Path(__file__).resolve().parent.parent.parent INSTALLED_APPS = [ 'django.contrib.admin', @@ -64,18 +57,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'marietje.wsgi.application' -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'marietje', - 'USER': 'marietje', - 'PASSWORD': 'v8TzZwdAdSi7Tk5I', - 'HOST': 'localhost', - 'PORT': '3306', - 'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"}, - } -} - AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', @@ -147,12 +128,6 @@ OAUTH2_PROVIDER = { }, } - -# zc files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.10/howto/static-files/ - -BASE_URL = 'https://marietje-zuid.science.ru.nl' - STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' LOGIN_URL = '/login/' @@ -164,10 +139,8 @@ LOGOUT_REDIRECT_URL = '/' DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" -# App specific settings - -BERTHA_HOST = ('bach.science.ru.nl', 1234) MAIL_FROM = 'marietje@marietje.science.ru.nl' + MAX_MINUTES_IN_A_ROW = 45 # Time range (dependent on timezone specified) when MAX_MINUTES_IN_A_ROW is in effect. diff --git a/marietje/marietje/settings/development.py b/marietje/marietje/settings/development.py new file mode 100644 index 0000000..c31ae2e --- /dev/null +++ b/marietje/marietje/settings/development.py @@ -0,0 +1,20 @@ +import os + +from .base import * + +SECRET_KEY = 'sae2hahHao1soo0Ocoz5Ieh1Ushae6feJe4mooliooj0Ula8' + +DEBUG = False + +ALLOWED_HOSTS = ['*'] + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), + } +} + +BERTHA_HOST = ('localhost', 1234) + +BASE_URL = 'http://localhost:8000' diff --git a/marietje/marietje/settings/production.py.example b/marietje/marietje/settings/production.py.example new file mode 100644 index 0000000..2be9f0e --- /dev/null +++ b/marietje/marietje/settings/production.py.example @@ -0,0 +1,23 @@ +from .base import * + +SECRET_KEY = '******' + +DEBUG = False + +ALLOWED_HOSTS = ['marietje-zuid.nl'] + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'marietje', + 'USER': 'marietje', + 'PASSWORD': '******', + 'HOST': 'localhost', + 'PORT': '3306', + 'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"}, + } +} + +BASE_URL = 'https://marietje-zuid.science.ru.nl' + +BERTHA_HOST = ('bach.science.ru.nl', 1234) \ No newline at end of file