-
Notifications
You must be signed in to change notification settings - Fork 70
/
settings.py
171 lines (148 loc) · 4.6 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
"""
Django settings for reference server.
"""
import os
import environ
from django.utils.translation import gettext_lazy as _
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
env = environ.Env()
env_file = os.environ["ENV_PATH"] if os.environ.get("ENV_PATH") else os.path.join(BASE_DIR, ".env")
if os.path.exists(env_file):
environ.Env.read_env(env_file)
SECRET_KEY = env("DJANGO_SECRET_KEY")
MULT_ASSET_ADDITIONAL_SIGNING_SEED = env(
"MULT_ASSET_ADDITIONAL_SIGNING_SEED", default=None
)
DEBUG = env.bool("DJANGO_DEBUG", False)
ALLOWED_HOSTS = env.list(
"DJANGO_ALLOWED_HOSTS", default=["localhost", "127.0.0.1", "[::1]", "0.0.0.0"]
)
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"corsheaders",
"server",
"polaris",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"polaris.middleware.TimezoneMiddleware",
]
local_mode = env.bool("LOCAL_MODE", default=False)
SESSION_COOKIE_SECURE = not local_mode
SECURE_SSL_REDIRECT = not local_mode
if SECURE_SSL_REDIRECT:
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
APPEND_SLASH = False
ROOT_URLCONF = "server.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 = "server.wsgi.application"
DATABASES = {
"default": env.db(
"DATABASE_URL",
default="sqlite:////" + os.path.join(BASE_DIR, "data/db.sqlite3"),
)
}
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
LANGUAGE_CODE = "en-us"
TIME_ZONE = "America/Los_Angeles"
USE_I18N = True
USE_L10N = True
USE_TZ = True
USE_THOUSAND_SEPARATOR = True
LANGUAGES = [
("en", _("English")),
("pt", _("Portuguese")),
("id", _("Bahasa Indonesia")),
]
FORM_RENDERER = "django.forms.renderers.TemplatesSetting"
STATIC_ROOT = os.path.join(BASE_DIR, "server/collectstatic")
STATIC_URL = "/static/"
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
"DEFAULT_RENDERER_CLASSES": [
"rest_framework.renderers.JSONRenderer",
"rest_framework.renderers.BrowsableAPIRenderer",
"rest_framework.renderers.TemplateHTMLRenderer",
],
"PAGE_SIZE": 10,
}
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = env("EMAIL_HOST_USER", default=None)
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD", default=None)
EMAIL_USE_TLS = True
EMAIL_PORT = 587
CORS_ORIGIN_ALLOW_ALL = True
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"formatters": {
"polaris": {
"format": "{asctime} - {levelname} - {name}:{lineno} - {message}",
"style": "{",
"datefmt": "%Y-%m-%dT%H:%M:%SZ",
},
"default": {
"format": "{asctime} - {levelname} - {name} - {message}",
"style": "{",
"datefmt": "%Y-%m-%dT%H:%M:%SZ",
},
},
"handlers": {
"polaris-console": {
"class": "logging.StreamHandler",
"level": "DEBUG",
"formatter": "polaris",
},
"default-console": {
"class": "logging.StreamHandler",
"level": "DEBUG",
"formatter": "default",
},
},
"loggers": {
"server": {
"handlers": ["polaris-console"],
"propogate": False,
"level": "INFO",
},
"polaris": {
"handlers": ["polaris-console"],
"propogate": False,
"level": "DEBUG",
},
"django": {
"handlers": ["default-console"],
"propogate": False,
"level": "INFO",
},
},
}