Commit 01eeffc6fd793f66dc32e5099a61736cc06d2d20
1 parent
83e4896b05
Exists in
master
use redis for sessions too!
Showing 2 changed files with 4 additions and 1 deletions Inline Diff
flashy/settings.py
View file @
01eeffc
from datetime import datetime | 1 | 1 | from datetime import datetime | |
2 | 2 | |||
import os | 3 | 3 | import os | |
from pytz import UTC | 4 | 4 | from pytz import UTC | |
5 | 5 | |||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 6 | 6 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
7 | 7 | |||
IN_PRODUCTION = 'FLASHY_PRODUCTION' in os.environ | 8 | 8 | IN_PRODUCTION = 'FLASHY_PRODUCTION' in os.environ | |
9 | 9 | |||
DEBUG = not IN_PRODUCTION | 10 | 10 | DEBUG = not IN_PRODUCTION | |
11 | 11 | |||
ALLOWED_HOSTS = ['127.0.0.1', 'flashy.cards'] | 12 | 12 | ALLOWED_HOSTS = ['127.0.0.1', 'flashy.cards'] | |
13 | 13 | |||
AUTH_USER_MODEL = 'flashcards.User' | 14 | 14 | AUTH_USER_MODEL = 'flashcards.User' | |
REST_FRAMEWORK = { | 15 | 15 | REST_FRAMEWORK = { | |
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', | 16 | 16 | 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', | |
'PAGE_SIZE': 20 | 17 | 17 | 'PAGE_SIZE': 20 | |
} | 18 | 18 | } | |
19 | 19 | |||
INSTALLED_APPS = [ | 20 | 20 | INSTALLED_APPS = [ | |
'simple_email_confirmation', | 21 | 21 | 'simple_email_confirmation', | |
'flashcards', | 22 | 22 | 'flashcards', | |
'django.contrib.admin', | 23 | 23 | 'django.contrib.admin', | |
'django.contrib.admindocs', | 24 | 24 | 'django.contrib.admindocs', | |
'django.contrib.auth', | 25 | 25 | 'django.contrib.auth', | |
'django.contrib.contenttypes', | 26 | 26 | 'django.contrib.contenttypes', | |
'django.contrib.sessions', | 27 | 27 | 'django.contrib.sessions', | |
'django.contrib.messages', | 28 | 28 | 'django.contrib.messages', | |
'django.contrib.staticfiles', | 29 | 29 | 'django.contrib.staticfiles', | |
'ws4redis', | 30 | 30 | 'ws4redis', | |
31 | 31 | |||
'rest_framework_swagger', | 32 | 32 | 'rest_framework_swagger', | |
'rest_framework', | 33 | 33 | 'rest_framework', | |
'django_extensions', | 34 | 34 | 'django_extensions', | |
] | 35 | 35 | ] | |
36 | 36 | |||
WEBSOCKET_URL = '/ws/' | 37 | 37 | WEBSOCKET_URL = '/ws/' | |
38 | 38 | |||
MIDDLEWARE_CLASSES = ( | 39 | 39 | MIDDLEWARE_CLASSES = ( | |
'flashcards.middleware.SetRemoteAddrFromForwardedFor', | 40 | 40 | 'flashcards.middleware.SetRemoteAddrFromForwardedFor', | |
'django.contrib.sessions.middleware.SessionMiddleware', | 41 | 41 | 'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | 42 | 42 | 'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | 43 | 43 | 'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | 44 | 44 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | 45 | 45 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | 46 | 46 | 'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | 47 | 47 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
'django.middleware.security.SecurityMiddleware', | 48 | 48 | 'django.middleware.security.SecurityMiddleware', | |
49 | 49 | |||
) | 50 | 50 | ) | |
51 | 51 | |||
ROOT_URLCONF = 'flashy.urls' | 52 | 52 | ROOT_URLCONF = 'flashy.urls' | |
53 | 53 | |||
AUTHENTICATION_BACKENDS = ( | 54 | 54 | AUTHENTICATION_BACKENDS = ( | |
'django.contrib.auth.backends.ModelBackend', | 55 | 55 | 'django.contrib.auth.backends.ModelBackend', | |
) | 56 | 56 | ) | |
57 | 57 | |||
TEMPLATES = [ | 58 | 58 | TEMPLATES = [ | |
{ | 59 | 59 | { | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | 60 | 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': ['templates/'], | 61 | 61 | 'DIRS': ['templates/'], | |
'APP_DIRS': True, | 62 | 62 | 'APP_DIRS': True, | |
'OPTIONS': { | 63 | 63 | 'OPTIONS': { | |
'context_processors': [ | 64 | 64 | 'context_processors': [ | |
'django.template.context_processors.debug', | 65 | 65 | 'django.template.context_processors.debug', | |
'django.template.context_processors.request', | 66 | 66 | 'django.template.context_processors.request', | |
'django.contrib.auth.context_processors.auth', | 67 | 67 | 'django.contrib.auth.context_processors.auth', | |
'django.contrib.messages.context_processors.messages', | 68 | 68 | 'django.contrib.messages.context_processors.messages', | |
'django.core.context_processors.static', | 69 | 69 | 'django.core.context_processors.static', | |
'ws4redis.context_processors.default', | 70 | 70 | 'ws4redis.context_processors.default', | |
], | 71 | 71 | ], | |
}, | 72 | 72 | }, | |
}, | 73 | 73 | }, | |
] | 74 | 74 | ] | |
75 | 75 | |||
WSGI_APPLICATION = 'ws4redis.django_runserver.application' | 76 | 76 | WSGI_APPLICATION = 'ws4redis.django_runserver.application' | |
77 | 77 | |||
DATABASES = { | 78 | 78 | DATABASES = { | |
'default': { | 79 | 79 | 'default': { | |
'ENGINE': 'django.db.backends.sqlite3', | 80 | 80 | 'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | 81 | 81 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | |
} | 82 | 82 | } | |
} | 83 | 83 | } | |
84 | 84 | |||
if IN_PRODUCTION: | 85 | 85 | if IN_PRODUCTION: | |
DATABASES['default'] = { | 86 | 86 | DATABASES['default'] = { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', | 87 | 87 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
'NAME': 'flashy', | 88 | 88 | 'NAME': 'flashy', | |
'USER': 'flashy', | 89 | 89 | 'USER': 'flashy', | |
'PASSWORD': os.environ['FLASHY_DB_PW'], | 90 | 90 | 'PASSWORD': os.environ['FLASHY_DB_PW'], | |
'HOST': 'localhost', | 91 | 91 | 'HOST': 'localhost', | |
'PORT': '', | 92 | 92 | 'PORT': '', | |
} | 93 | 93 | } | |
94 | 94 | |||
LANGUAGE_CODE = 'en-us' | 95 | 95 | LANGUAGE_CODE = 'en-us' | |
USE_I18N = True | 96 | 96 | USE_I18N = True | |
USE_L10N = True | 97 | 97 | USE_L10N = True | |
USE_TZ = True | 98 | 98 | USE_TZ = True | |
TIME_ZONE = 'America/Los_Angeles' | 99 | 99 | TIME_ZONE = 'America/Los_Angeles' | |
100 | 100 | |||
QUARTER_START = UTC.localize(datetime(2015, 3, 30)) | 101 | 101 | QUARTER_START = UTC.localize(datetime(2015, 3, 30)) | |
QUARTER_END = UTC.localize(datetime(2015, 6, 12)) | 102 | 102 | QUARTER_END = UTC.localize(datetime(2015, 6, 12)) | |
103 | 103 | |||
STATIC_URL = '/static/' | 104 | 104 | STATIC_URL = '/static/' | |
STATIC_ROOT = 'static' | 105 | 105 | STATIC_ROOT = 'static' | |
106 | 106 | |||
# Four settings just to be sure | 107 | 107 | # Four settings just to be sure | |
EMAIL_FROM = 'noreply@flashy.cards' | 108 | 108 | EMAIL_FROM = 'noreply@flashy.cards' | |
EMAIL_HOST_USER = 'noreply@flashy.cards' | 109 | 109 | EMAIL_HOST_USER = 'noreply@flashy.cards' | |
DEFAULT_FROM_EMAIL = 'noreply@flashy.cards' | 110 | 110 | DEFAULT_FROM_EMAIL = 'noreply@flashy.cards' | |
SERVER_EMAIL = 'noreply@flashy.cards' | 111 | 111 | SERVER_EMAIL = 'noreply@flashy.cards' | |
112 | 112 | |||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | 113 | 113 | EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | |
114 | 114 | |||
if IN_PRODUCTION: | 115 | 115 | if IN_PRODUCTION: | |
INSTALLED_APPS.append('django_ses') | 116 | 116 | INSTALLED_APPS.append('django_ses') | |
AWS_SES_REGION_NAME = 'us-west-2' | 117 | 117 | AWS_SES_REGION_NAME = 'us-west-2' | |
AWS_SES_REGION_ENDPOINT = 'email.us-west-2.amazonaws.com' | 118 | 118 | AWS_SES_REGION_ENDPOINT = 'email.us-west-2.amazonaws.com' | |
EMAIL_BACKEND = 'django_ses.SESBackend' | 119 | 119 | EMAIL_BACKEND = 'django_ses.SESBackend' | |
120 | 120 | |||
if IN_PRODUCTION: | 121 | 121 | if IN_PRODUCTION: | |
SESSION_COOKIE_SECURE = True | 122 | 122 | SESSION_COOKIE_SECURE = True | |
CSRF_COOKIE_SECURE = True | 123 | 123 | CSRF_COOKIE_SECURE = True | |
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | 124 | 124 | SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | |
# are we secure yet? | 125 | 125 | # are we secure yet? | |
126 | 126 | |||
if IN_PRODUCTION: | 127 | 127 | if IN_PRODUCTION: | |
LOGGING = { | 128 | 128 | LOGGING = { | |
'version': 1, | 129 | 129 | 'version': 1, | |
'disable_existing_loggers': False, | 130 | 130 | 'disable_existing_loggers': False, | |
'handlers': { | 131 | 131 | 'handlers': { | |
'file': { | 132 | 132 | 'file': { | |
'level': 'DEBUG', | 133 | 133 | 'level': 'DEBUG', | |
'class': 'logging.FileHandler', | 134 | 134 | 'class': 'logging.FileHandler', | |
'filename': 'debug.log', | 135 | 135 | 'filename': 'debug.log', | |
}, | 136 | 136 | }, | |
'eventslog': { | 137 | 137 | 'eventslog': { | |
'level': 'INFO', | 138 | 138 | 'level': 'INFO', | |
'class': 'logging.FileHandler', | 139 | 139 | 'class': 'logging.FileHandler', | |
'filename': 'events.log', | 140 | 140 | 'filename': 'events.log', | |
'formatter': 'verbose' | 141 | 141 | 'formatter': 'verbose' | |
}, | 142 | 142 | }, | |
}, | 143 | 143 | }, | |
'formatters': { | 144 | 144 | 'formatters': { | |
'verbose': { | 145 | 145 | 'verbose': { | |
'format': '%(asctime)s %(module)s %(message)s' | 146 | 146 | 'format': '%(asctime)s %(module)s %(message)s' | |
}, | 147 | 147 | }, | |
}, | 148 | 148 | }, |
requirements.txt
View file @
01eeffc
#beautifulsoup4 | 1 | 1 | #beautifulsoup4 | |
Django>=1.8 | 2 | 2 | Django>=1.8 | |
django-websocket-redis | 3 | 3 | django-websocket-redis | |
#gevent==1.0.1 | 4 | 4 | #gevent==1.0.1 | |
#greenlet==0.4.5 | 5 | 5 | #greenlet==0.4.5 | |
redis==2.10.3 | 6 | 6 | redis==2.10.3 | |
six==1.9.0 | 7 | 7 | six==1.9.0 | |
cached-property | 8 | 8 | cached-property | |
djangorestframework | 9 | 9 | djangorestframework | |
docutils | 10 | 10 | docutils | |
django-simple-email-confirmation | 11 | 11 | django-simple-email-confirmation | |
coverage | 12 | 12 | coverage | |
django-rest-swagger | 13 | 13 | django-rest-swagger | |
pytz | 14 | 14 | pytz | |
django-extensions | 15 | 15 | django-extensions | |
django-filter | 16 | 16 | django-redis-sessions | |