Commit dda84e6b0013583edb88fb5d5d620c0a2fbb1035
1 parent
0b29a62e06
Exists in
master
delay end of quarter by a month
Showing 1 changed file with 1 additions and 1 deletions Inline Diff
flashy/settings.py
View file @
dda84e6
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 | |||
if DEBUG: | 14 | 14 | if DEBUG: | |
ABSOLUTE_URL_ROOT = 'http://127.0.0.1:8080/' | 15 | 15 | ABSOLUTE_URL_ROOT = 'http://127.0.0.1:8080/' | |
else: | 16 | 16 | else: | |
ABSOLUTE_URL_ROOT = 'https://flashy.cards/' | 17 | 17 | ABSOLUTE_URL_ROOT = 'https://flashy.cards/' | |
18 | 18 | |||
AUTH_USER_MODEL = 'flashcards.User' | 19 | 19 | AUTH_USER_MODEL = 'flashcards.User' | |
REST_FRAMEWORK = { | 20 | 20 | REST_FRAMEWORK = { | |
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', | 21 | 21 | 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', | |
'PAGE_SIZE': 20, | 22 | 22 | 'PAGE_SIZE': 20, | |
'DEFAULT_THROTTLE_CLASSES': ( | 23 | 23 | 'DEFAULT_THROTTLE_CLASSES': ( | |
'rest_framework.throttling.UserRateThrottle', | 24 | 24 | 'rest_framework.throttling.UserRateThrottle', | |
), | 25 | 25 | ), | |
} | 26 | 26 | } | |
27 | 27 | |||
INSTALLED_APPS = [ | 28 | 28 | INSTALLED_APPS = [ | |
'simple_email_confirmation', | 29 | 29 | 'simple_email_confirmation', | |
'flashcards', | 30 | 30 | 'flashcards', | |
'django.contrib.admin', | 31 | 31 | 'django.contrib.admin', | |
'django.contrib.admindocs', | 32 | 32 | 'django.contrib.admindocs', | |
'django.contrib.auth', | 33 | 33 | 'django.contrib.auth', | |
'django.contrib.contenttypes', | 34 | 34 | 'django.contrib.contenttypes', | |
'django.contrib.sessions', | 35 | 35 | 'django.contrib.sessions', | |
'django.contrib.messages', | 36 | 36 | 'django.contrib.messages', | |
'django.contrib.staticfiles', | 37 | 37 | 'django.contrib.staticfiles', | |
'ws4redis', | 38 | 38 | 'ws4redis', | |
'rest_framework_swagger', | 39 | 39 | 'rest_framework_swagger', | |
'rest_framework', | 40 | 40 | 'rest_framework', | |
'django_extensions', | 41 | 41 | 'django_extensions', | |
] | 42 | 42 | ] | |
43 | 43 | |||
WEBSOCKET_URL = '/ws/' | 44 | 44 | WEBSOCKET_URL = '/ws/' | |
45 | 45 | |||
MIDDLEWARE_CLASSES = ( | 46 | 46 | MIDDLEWARE_CLASSES = ( | |
'flashcards.middleware.SetRemoteAddrFromForwardedFor', | 47 | 47 | 'flashcards.middleware.SetRemoteAddrFromForwardedFor', | |
'django.contrib.sessions.middleware.SessionMiddleware', | 48 | 48 | 'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | 49 | 49 | 'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | 50 | 50 | 'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | 51 | 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | 52 | 52 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | 53 | 53 | 'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | 54 | 54 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
'django.middleware.security.SecurityMiddleware', | 55 | 55 | 'django.middleware.security.SecurityMiddleware', | |
56 | 56 | |||
) | 57 | 57 | ) | |
58 | 58 | |||
ROOT_URLCONF = 'flashy.urls' | 59 | 59 | ROOT_URLCONF = 'flashy.urls' | |
60 | 60 | |||
AUTHENTICATION_BACKENDS = ( | 61 | 61 | AUTHENTICATION_BACKENDS = ( | |
'django.contrib.auth.backends.ModelBackend', | 62 | 62 | 'django.contrib.auth.backends.ModelBackend', | |
) | 63 | 63 | ) | |
64 | 64 | |||
TEMPLATES = [ | 65 | 65 | TEMPLATES = [ | |
{ | 66 | 66 | { | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | 67 | 67 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': ['templates/'], | 68 | 68 | 'DIRS': ['templates/'], | |
'APP_DIRS': True, | 69 | 69 | 'APP_DIRS': True, | |
'OPTIONS': { | 70 | 70 | 'OPTIONS': { | |
'context_processors': [ | 71 | 71 | 'context_processors': [ | |
'django.template.context_processors.debug', | 72 | 72 | 'django.template.context_processors.debug', | |
'django.template.context_processors.request', | 73 | 73 | 'django.template.context_processors.request', | |
'django.contrib.auth.context_processors.auth', | 74 | 74 | 'django.contrib.auth.context_processors.auth', | |
'django.contrib.messages.context_processors.messages', | 75 | 75 | 'django.contrib.messages.context_processors.messages', | |
'django.core.context_processors.static', | 76 | 76 | 'django.core.context_processors.static', | |
'ws4redis.context_processors.default', | 77 | 77 | 'ws4redis.context_processors.default', | |
], | 78 | 78 | ], | |
}, | 79 | 79 | }, | |
}, | 80 | 80 | }, | |
] | 81 | 81 | ] | |
82 | 82 | |||
WSGI_APPLICATION = 'ws4redis.django_runserver.application' | 83 | 83 | WSGI_APPLICATION = 'ws4redis.django_runserver.application' | |
84 | 84 | |||
DATABASES = { | 85 | 85 | DATABASES = { | |
'default': { | 86 | 86 | 'default': { | |
'ENGINE': 'django.db.backends.sqlite3', | 87 | 87 | 'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | 88 | 88 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | |
} | 89 | 89 | } | |
} | 90 | 90 | } | |
91 | 91 | |||
if IN_PRODUCTION: | 92 | 92 | if IN_PRODUCTION: | |
DATABASES['default'] = { | 93 | 93 | DATABASES['default'] = { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', | 94 | 94 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
'NAME': 'flashy', | 95 | 95 | 'NAME': 'flashy', | |
'USER': 'flashy', | 96 | 96 | 'USER': 'flashy', | |
'PASSWORD': os.environ['FLASHY_DB_PW'], | 97 | 97 | 'PASSWORD': os.environ['FLASHY_DB_PW'], | |
'HOST': 'localhost', | 98 | 98 | 'HOST': 'localhost', | |
'PORT': '', | 99 | 99 | 'PORT': '', | |
} | 100 | 100 | } | |
101 | 101 | |||
LANGUAGE_CODE = 'en-us' | 102 | 102 | LANGUAGE_CODE = 'en-us' | |
USE_I18N = True | 103 | 103 | USE_I18N = True | |
USE_L10N = True | 104 | 104 | USE_L10N = True | |
USE_TZ = True | 105 | 105 | USE_TZ = True | |
TIME_ZONE = 'America/Los_Angeles' | 106 | 106 | TIME_ZONE = 'America/Los_Angeles' | |
107 | 107 | |||
QUARTER_START = UTC.localize(datetime(2015, 3, 30)) | 108 | 108 | QUARTER_START = UTC.localize(datetime(2015, 3, 30)) | |
QUARTER_END = UTC.localize(datetime(2015, 6, 12)) | 109 | 109 | QUARTER_END = UTC.localize(datetime(2015, 7, 12)) | |
110 | 110 | |||
STATIC_URL = '/static/' | 111 | 111 | STATIC_URL = '/static/' | |
STATIC_ROOT = 'static' | 112 | 112 | STATIC_ROOT = 'static' | |
113 | 113 | |||
# Four settings just to be sure | 114 | 114 | # Four settings just to be sure | |
EMAIL_FROM = 'noreply@flashy.cards' | 115 | 115 | EMAIL_FROM = 'noreply@flashy.cards' | |
EMAIL_HOST_USER = 'noreply@flashy.cards' | 116 | 116 | EMAIL_HOST_USER = 'noreply@flashy.cards' | |
DEFAULT_FROM_EMAIL = 'noreply@flashy.cards' | 117 | 117 | DEFAULT_FROM_EMAIL = 'noreply@flashy.cards' | |
SERVER_EMAIL = 'noreply@flashy.cards' | 118 | 118 | SERVER_EMAIL = 'noreply@flashy.cards' | |
119 | 119 | |||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | 120 | 120 | EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | |
121 | 121 | |||
if DEBUG: | 122 | 122 | if DEBUG: | |
INSTALLED_APPS.append('debug_toolbar') | 123 | 123 | INSTALLED_APPS.append('debug_toolbar') | |
# DEBUG_TOOLBAR_PANELS = ['debug_toolbar.panels.profiling.ProfilingPanel'] | 124 | 124 | # DEBUG_TOOLBAR_PANELS = ['debug_toolbar.panels.profiling.ProfilingPanel'] | |
125 | 125 | |||
if IN_PRODUCTION: | 126 | 126 | if IN_PRODUCTION: | |
INSTALLED_APPS.append('django_ses') | 127 | 127 | INSTALLED_APPS.append('django_ses') | |
AWS_SES_REGION_NAME = 'us-west-2' | 128 | 128 | AWS_SES_REGION_NAME = 'us-west-2' | |
AWS_SES_REGION_ENDPOINT = 'email.us-west-2.amazonaws.com' | 129 | 129 | AWS_SES_REGION_ENDPOINT = 'email.us-west-2.amazonaws.com' | |
EMAIL_BACKEND = 'django_ses.SESBackend' | 130 | 130 | EMAIL_BACKEND = 'django_ses.SESBackend' | |
131 | 131 | |||
if IN_PRODUCTION: | 132 | 132 | if IN_PRODUCTION: | |
SESSION_COOKIE_SECURE = True | 133 | 133 | SESSION_COOKIE_SECURE = True | |
CSRF_COOKIE_SECURE = True | 134 | 134 | CSRF_COOKIE_SECURE = True | |
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | 135 | 135 | SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | |
# are we secure yet? | 136 | 136 | # are we secure yet? | |
137 | 137 | |||
if IN_PRODUCTION: | 138 | 138 | if IN_PRODUCTION: | |
LOGGING = { | 139 | 139 | LOGGING = { | |
'version': 1, | 140 | 140 | 'version': 1, | |
'disable_existing_loggers': False, | 141 | 141 | 'disable_existing_loggers': False, | |
'handlers': { | 142 | 142 | 'handlers': { | |
'file': { | 143 | 143 | 'file': { | |
'level': 'DEBUG', | 144 | 144 | 'level': 'DEBUG', | |
'class': 'logging.FileHandler', | 145 | 145 | 'class': 'logging.FileHandler', | |
'filename': 'debug.log', | 146 | 146 | 'filename': 'debug.log', | |
}, | 147 | 147 | }, | |
'eventslog': { | 148 | 148 | 'eventslog': { | |
'level': 'INFO', | 149 | 149 | 'level': 'INFO', | |
'class': 'logging.FileHandler', | 150 | 150 | 'class': 'logging.FileHandler', | |
'filename': 'events.log', | 151 | 151 | 'filename': 'events.log', | |
'formatter': 'verbose' | 152 | 152 | 'formatter': 'verbose' | |
}, | 153 | 153 | }, | |
}, | 154 | 154 | }, | |
'formatters': { | 155 | 155 | 'formatters': { | |
'verbose': { | 156 | 156 | 'verbose': { | |
'format': '%(asctime)s %(module)s %(message)s' | 157 | 157 | 'format': '%(asctime)s %(module)s %(message)s' | |
}, | 158 | 158 | }, | |
}, | 159 | 159 | }, | |
'loggers': { | 160 | 160 | 'loggers': { | |
'django': { | 161 | 161 | 'django': { | |
'handlers': ['file'], | 162 | 162 | 'handlers': ['file'], |