From 432e55aae4a1db2771cf347956fcf6a6efd43a33 Mon Sep 17 00:00:00 2001 From: Michael Kelly Date: Tue, 22 Dec 2015 14:00:41 -0800 Subject: [PATCH] omg omg omg --- .gitignore | 5 +++ manage.py | 11 +++++ normandy/__init__.py | 0 normandy/settings.py | 98 ++++++++++++++++++++++++++++++++++++++++++++ normandy/urls.py | 7 ++++ normandy/wsgi.py | 11 +++++ requirements.txt | 6 +++ 7 files changed, 138 insertions(+) create mode 100644 .gitignore create mode 100755 manage.py create mode 100644 normandy/__init__.py create mode 100644 normandy/settings.py create mode 100644 normandy/urls.py create mode 100644 normandy/wsgi.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..750776e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.env +db.sqlite3 +.DS_Store +/static/ +/media/ diff --git a/manage.py b/manage.py new file mode 100755 index 00000000..c654141e --- /dev/null +++ b/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "normandy.settings") + os.environ.setdefault('DJANGO_CONFIGURATION', 'Development') + + from configurations.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/normandy/__init__.py b/normandy/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/normandy/settings.py b/normandy/settings.py new file mode 100644 index 00000000..624101b9 --- /dev/null +++ b/normandy/settings.py @@ -0,0 +1,98 @@ +import os + +from configurations import Configuration, values + + +class Core(Configuration): + """Settings that will never change per-environment.""" + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) + BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + # Application definition + INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + ] + + MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + ] + + ROOT_URLCONF = 'normandy.urls' + + TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'normandy.wsgi.application' + + # Internationalization + LANGUAGE_CODE = 'en-us' + TIME_ZONE = 'UTC' + USE_I18N = False + USE_L10N = False + USE_TZ = True + + # Static files (CSS, JavaScript, Images) + STATIC_URL = '/static/' + STATIC_ROOT = os.path.join(BASE_DIR, 'static') + + +class Base(Core): + """Settings that may change per-environment, some with defaults.""" + SECRET_KEY = values.SecretValue() + DEBUG = values.BooleanValue(False) + ALLOWED_HOSTS = values.ListValue([]) + DATABASES = values.DatabaseURLValue('sqlite:///db.sqlite3') + + # Password validation + 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', + }, + ] + + +class Development(Base): + """Settings for local development.""" + DOTENV = '.env' + SECRET_KEY = values.Value('not a secret') + DEBUG = values.BooleanValue(True) + AUTH_PASSWORD_VALIDATORS = values.ListValue([]) + + +class Production(Base): + """Settings for the production environment.""" + STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' diff --git a/normandy/urls.py b/normandy/urls.py new file mode 100644 index 00000000..d52422ef --- /dev/null +++ b/normandy/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url +from django.contrib import admin + + +urlpatterns = [ + url(r'^admin/', admin.site.urls), +] diff --git a/normandy/wsgi.py b/normandy/wsgi.py new file mode 100644 index 00000000..fdd2218d --- /dev/null +++ b/normandy/wsgi.py @@ -0,0 +1,11 @@ +import os + +from configurations.wsgi import get_wsgi_application +from whitenoise.django import DjangoWhiteNoise + + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "normandy.settings") +os.environ.setdefault('DJANGO_CONFIGURATION', 'Production') + + +application = DjangoWhiteNoise(get_wsgi_application()) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..8ca7355d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +dj-database-url==0.3.0 +Django==1.9 +https://github.com/jazzband/django-configurations/archive/afb057f33bc27311b448832fb9eede8935faec87.zip#egg=django-configurations==0.9dev +wheel==0.24.0 +whitenoise==2.0.6 +psycopg2==2.6.1