diff --git a/CollegiateHouseWars/settings.py b/CollegiateHouseWars/settings.py index e260a1e..09d63cd 100644 --- a/CollegiateHouseWars/settings.py +++ b/CollegiateHouseWars/settings.py @@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/ """ from pathlib import Path -from decouple import Config, RepositoryEnv +import os from django.contrib.messages import constants # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -23,8 +23,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # SECURITY WARNING: keep the secret key used in production secret! DOTENV_FILE = BASE_DIR / '.env' -env_config = Config(RepositoryEnv(DOTENV_FILE)) -SECRET_KEY = env_config.get('SECRET_KEY') +SECRET_KEY = os.environ.get('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -91,6 +90,12 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', + }, + 'production': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': os.environ.get('DATABASE_NAME'), + 'USER': os.environ.get('DATABASE_USERNAME'), + 'PASSWORD': os.environ.get('DATABASE_PASSWORD'), } } diff --git a/CollegiateHouseWars/test_settings.py b/CollegiateHouseWars/test_settings.py new file mode 100644 index 0000000..df8f3ac --- /dev/null +++ b/CollegiateHouseWars/test_settings.py @@ -0,0 +1,144 @@ +""" +Django settings for CollegiateHouseWars project. + +Generated by 'django-admin startproject' using Django 4.0.4. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.0/ref/settings/ +""" + +from pathlib import Path +import os +from django.contrib.messages import constants + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +DOTENV_FILE = BASE_DIR / '.env' +SECRET_KEY = os.environ.get('SECRET_KEY') + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +SECURE_SSL_REDIRECT = False +SESSION_COOKIE_SECURE = False +CSRF_COOKIE_SECURE = False + +ALLOWED_HOSTS = [ + 'localhost', + '127.0.0.1' +] + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'formtools', + + 'housewars.apps.HousewarsConfig' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'CollegiateHouseWars.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [BASE_DIR / 'templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'CollegiateHouseWars.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.0/howto/static-files/ + +STATIC_URL = 'static/' +STATIC_ROOT = BASE_DIR / 'static/src' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + + +MESSAGE_TAGS = {constants.DEBUG: 'debug', + constants.INFO: 'info', + constants.SUCCESS: 'success', + constants.WARNING: 'warning', + constants.ERROR: 'danger', } diff --git a/manage.py b/manage.py index 6fccf0b..8c0ae3d 100644 --- a/manage.py +++ b/manage.py @@ -3,10 +3,16 @@ import os import sys +from dotenv import load_dotenv +from pathlib import Path + +load_dotenv(Path('.env')) + def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CollegiateHouseWars.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', + 'CollegiateHouseWars.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/requirements.txt b/requirements.txt index 5dad2c7..da044f2 100644 Binary files a/requirements.txt and b/requirements.txt differ