/
settings.py
245 lines (209 loc) · 7.63 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import os
DEBUG = False
WAGTAIL_ROOT = os.path.dirname(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(WAGTAIL_ROOT, 'tests', 'test-static')
MEDIA_ROOT = os.path.join(WAGTAIL_ROOT, 'tests', 'test-media')
MEDIA_URL = '/media/'
TIME_ZONE = 'Asia/Tokyo'
DATABASES = {
'default': {
'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.sqlite3'),
'NAME': os.environ.get('DATABASE_NAME', 'wagtail'),
'USER': os.environ.get('DATABASE_USER', None),
'PASSWORD': os.environ.get('DATABASE_PASS', None),
'HOST': os.environ.get('DATABASE_HOST', None),
'TEST': {
'NAME': os.environ.get('DATABASE_NAME', None),
}
}
}
# Add extra options when mssql is used (on for example appveyor)
if DATABASES['default']['ENGINE'] == 'sql_server.pyodbc':
DATABASES['default']['OPTIONS'] = {
'driver': 'SQL Server Native Client 11.0',
'MARS_Connection': 'True',
}
# explicitly set charset / collation to utf8 on mysql
if DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
DATABASES['default']['TEST']['CHARSET'] = 'utf8'
DATABASES['default']['TEST']['COLLATION'] = 'utf8_general_ci'
SECRET_KEY = 'not needed'
ROOT_URLCONF = 'wagtail.tests.urls'
STATIC_URL = '/static/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
USE_TZ = not os.environ.get('DISABLE_TIMEZONE')
if not USE_TZ:
print("Timezone support disabled")
LANGUAGE_CODE = "en"
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',
'django.template.context_processors.request',
'wagtail.tests.context_processors.do_not_use_static_url',
'wagtail.contrib.settings.context_processors.settings',
],
'debug': True, # required in order to catch template errors
},
},
{
'BACKEND': 'django.template.backends.jinja2.Jinja2',
'APP_DIRS': False,
'DIRS': [
os.path.join(WAGTAIL_ROOT, 'tests', 'testapp', 'jinja2_templates'),
],
'OPTIONS': {
'extensions': [
'wagtail.core.jinja2tags.core',
'wagtail.admin.jinja2tags.userbar',
'wagtail.images.jinja2tags.images',
'wagtail.contrib.settings.jinja2tags.settings',
],
},
},
]
MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'wagtail.tests.middleware.BlockDodgyUserAgentMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
)
INSTALLED_APPS = [
# Install wagtailredirects with its appconfig
# Theres nothing special about wagtailredirects, we just need to have one
# app which uses AppConfigs to test that hooks load properly
'wagtail.contrib.redirects.apps.WagtailRedirectsAppConfig',
'wagtail.tests.testapp',
'wagtail.tests.demosite',
'wagtail.tests.snippets',
'wagtail.tests.routablepage',
'wagtail.tests.search',
'wagtail.tests.modeladmintest',
'wagtail.tests.i18n',
'wagtail.contrib.styleguide',
'wagtail.contrib.routable_page',
'wagtail.contrib.frontend_cache',
'wagtail.contrib.search_promotions',
'wagtail.contrib.settings',
'wagtail.contrib.modeladmin',
'wagtail.contrib.table_block',
'wagtail.contrib.forms',
'wagtail.search',
'wagtail.embeds',
'wagtail.images',
'wagtail.sites',
'wagtail.locales',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.admin',
'wagtail.api.v2',
'wagtail.core',
'taggit',
'rest_framework',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
]
# Using DatabaseCache to make sure that the cache is cleared between tests.
# This prevents false-positives in some wagtail core tests where we are
# changing the 'wagtail_root_paths' key which may cause future tests to fail.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'cache',
}
}
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher', # don't use the intentionally slow default password hasher
)
ALLOWED_HOSTS = ['localhost', 'testserver', 'other.example.com']
WAGTAILSEARCH_BACKENDS = {
'default': {
'BACKEND': 'wagtail.search.backends.db',
}
}
if os.environ.get('USE_EMAIL_USER_MODEL'):
INSTALLED_APPS.append('wagtail.tests.emailuser')
AUTH_USER_MODEL = 'emailuser.EmailUser'
print("EmailUser (no username) user model active")
else:
INSTALLED_APPS.append('wagtail.tests.customuser')
AUTH_USER_MODEL = 'customuser.CustomUser'
# Extra user field for custom user edit and create form tests. This setting
# needs to here because it is used at the module level of wagtailusers.forms
# when the module gets loaded. The decorator 'override_settings' does not work
# in this scenario.
WAGTAIL_USER_CUSTOM_FIELDS = ['country', 'attachment']
if os.environ.get('DATABASE_ENGINE') == 'django.db.backends.postgresql':
INSTALLED_APPS += ('wagtail.contrib.postgres_search',)
WAGTAILSEARCH_BACKENDS['postgresql'] = {
'BACKEND': 'wagtail.contrib.postgres_search.backend',
'AUTO_UPDATE': False,
'SEARCH_CONFIG': 'english'
}
if 'ELASTICSEARCH_URL' in os.environ:
if os.environ.get('ELASTICSEARCH_VERSION') == '7':
backend = 'wagtail.search.backends.elasticsearch7'
elif os.environ.get('ELASTICSEARCH_VERSION') == '6':
backend = 'wagtail.search.backends.elasticsearch6'
elif os.environ.get('ELASTICSEARCH_VERSION') == '5':
backend = 'wagtail.search.backends.elasticsearch5'
elif os.environ.get('ELASTICSEARCH_VERSION') == '2':
backend = 'wagtail.search.backends.elasticsearch2'
WAGTAILSEARCH_BACKENDS['elasticsearch'] = {
'BACKEND': backend,
'URLS': [os.environ['ELASTICSEARCH_URL']],
'TIMEOUT': 10,
'max_retries': 1,
'AUTO_UPDATE': False,
'INDEX_SETTINGS': {
'settings': {
'index': {
'number_of_shards': 1
}
}
}
}
WAGTAIL_SITE_NAME = "Test Site"
WAGTAILADMIN_RICH_TEXT_EDITORS = {
'default': {
'WIDGET': 'wagtail.admin.rich_text.DraftailRichTextArea'
},
'hallo': {
'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
},
'custom': {
'WIDGET': 'wagtail.tests.testapp.rich_text.CustomRichTextArea'
},
}
WAGTAIL_CONTENT_LANGUAGES = [
("en", "English"),
("fr", "French"),
]
# Set a non-standard DEFAULT_AUTHENTICATION_CLASSES value, to verify that the
# admin API still works with session-based auth regardless of this setting
# (see https://github.com/wagtail/wagtail/issues/5585)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
]
}