Skip to content

Commit

Permalink
testing and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Jul 5, 2016
1 parent 916a654 commit 737e142
Show file tree
Hide file tree
Showing 12 changed files with 453 additions and 123 deletions.
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: python
python:
- '3.5.1'

before_install:
- pip install nose
- pip install coverage
- pip install coveralls

install: pip install -r requirements.txt

before_script:
- psql -c 'create database minent;' -U postgres

script: make test

after_success: coveralls

env:
global:
- DJANGO_SETTINGS_MODULE=minent.settings.testing
- SECRET_KEY=supersecretkey
- DATABASE_URL=postgres://localhost/minent
- EMAIL_HOST_USER=''
- EMAIL_HOST_PASSWORD=''
- GOOGLE_OAUTH2_KEY=''
- GOOGLE_OAUTH2_SECRET=''

notifications:
email:
recipients:
- bbengfort@districtdatalabs.com
- tojeda@districtdatalabs.com
- rbilbro@districtdatalabs.com
on_success: change
on_failure: always
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if __name__ == "__main__":
## Manage Django Environment
dotenv.read_dotenv()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "minent.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "minent.settings.production")

## Execute Django Utility
from django.core.management import execute_from_command_line
Expand Down
121 changes: 0 additions & 121 deletions minent/settings.py

This file was deleted.

18 changes: 18 additions & 0 deletions minent/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# minent.settings
# Settings module for the Minimum Entropy application
#
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created: Tue Jul 05 14:10:19 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: __init__.py [] benjamin@bengfort.com $

"""
Settings module for the Minimum Entropy application
"""

##########################################################################
## Imports
##########################################################################
209 changes: 209 additions & 0 deletions minent/settings/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# minent.settings.base
# The common Django settings for the minent project.
#
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created: Tue Jul 05 14:10:54 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: base.py [] benjamin@bengfort.com $

"""
The common Django settings for the minent project.
This file was adapated by the settings.py file generated by
'django-admin startproject' using Django 1.9.7.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""

##########################################################################
## Imports
##########################################################################

import os
import dj_database_url


##########################################################################
## Helper function for environmental settings
##########################################################################

def environ_setting(name, default=None):
"""
Fetch setting from the environment- if not found, then this setting is
ImproperlyConfigured.
"""
if name not in os.environ and default is None:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured(
"The {0} ENVVAR is not set.".format(name)
)

return os.environ.get(name, default)


##########################################################################
## Build Paths inside of project with os.path.join
##########################################################################

## Project is the location of the minent directory (with the wsgi.py)
## Note that BASE_DIR (originally in this file) is the same as Project
## Repository is the location of the project and the apps and other files
PROJECT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
REPOSITORY = os.path.dirname(PROJECT)


##########################################################################
## Secret settings - do not store!
##########################################################################

## SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = environ_setting("SECRET_KEY")

##########################################################################
## Database Settings
##########################################################################

## See" https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': dj_database_url.config(),
}

DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'

##########################################################################
## Runtime settings
##########################################################################

## Debugging settings
## SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

## Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

## Hosts - specify in production settings
ALLOWED_HOSTS = ["*"]
INTERNAL_IPS = ('127.0.0.1',)

## WSGI Configuration
ROOT_URLCONF = 'minent.urls'
WSGI_APPLICATION = 'minent.wsgi.application'

## Application definition
INSTALLED_APPS = [
# Django apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

# Third party apps

# Minimum Entropy apps
]

## Request Handling
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',
]

## Internationalization
## https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/New_York'
USE_I18N = True
USE_L10N = True
USE_TZ = True

## Admin Title
GRAPPELLI_ADMIN_TITLE = "Minimum Entropy Admin"

##########################################################################
## Content (Static, Media, Templates)
##########################################################################

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/assets/'

STATICFILES_DIRS = (
os.path.join(PROJECT, 'assets'),
)

# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

## Templates
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(PROJECT, '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',
],
},
},
]

##########################################################################
## Authentication
##########################################################################

## Password validation
## https://docs.djangoproject.com/en/1.9/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',
},
]

##########################################################################
## Logging and Error Reporting
##########################################################################

ADMINS = (
('Benjamin Bengfort', 'bbengfort@districtdatalabs.com'),
('Tony Ojeda', 'tojeda@districtdatalabs.com'),
('Rebecca Bilbro', 'rbilbro@districtdatalabs.com'),
)

SERVER_EMAIL = 'DDL Admin <admin@districtdatalabs.com>'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = environ_setting("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = environ_setting("EMAIL_HOST_PASSWORD")
EMAIL_PORT = 587
EMAIL_SUBJECT_PREFIX = '[MINENT] '
Loading

0 comments on commit 737e142

Please sign in to comment.