This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.py
435 lines (359 loc) · 13 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
import os
import environ
import oscar
from debug_toolbar import settings as dt_settings
env = environ.Env()
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
# Path helper
def location(x):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
DEV_APP_NAME = 'sophoshop'
DEBUG = env.bool('DEBUG', default=True)
# SQL_DEBUG = DEBUG
# TEMPLATE_DEBUG = DEBUG # NOQA (need for PIL convert error handle)
ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
'%s.herokuapp.com' % DEV_APP_NAME,
'192.168.1.101',
]
# This is needed for the hosted version of the sandbox
ADMINS = (
('David Winterbottom', '[email protected]'),
('Michael van Tellingen', '[email protected]'),
)
# region 'EMAIL'
EMAIL_SUBJECT_PREFIX = DEV_APP_NAME
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
MANAGERS = ADMINS
# endregion
# Use a Sqlite database by default
DATABASES = {
'default': {
'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.sqlite3'),
'NAME': os.environ.get('DATABASE_NAME', location('db.sqlite')),
'USER': os.environ.get('DATABASE_USER', None),
'PASSWORD': os.environ.get('DATABASE_PASSWORD', None),
'HOST': os.environ.get('DATABASE_HOST', None),
'PORT': os.environ.get('DATABASE_PORT', None),
'ATOMIC_REQUESTS': True
}
}
"""
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': '127.0.0.1:6379s',
},
"""
CACHES = {
'default': env.cache(default='locmemcache://'),
}
# почемуто не сохраняются значения атрибутов, похоже они уходят в кеш с концами
# SESSION_ENGINE = "django.contrib.sessions.backends.cache"
# SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
# SESSION_ENGINE = 'redis_sessions.session'
# SESSION_REDIS_UNIX_DOMAIN_SOCKET_PATH = '/var/run/redis/redis.sock'
SITE_ID = 1
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same timezone as the operating system.
# If running in a Windows environment this must be set to the same as your system time zone.
# USE_TZ = True
TIME_ZONE = 'Europe/Kiev'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'uk_UA'
# Includes all languages that have >50% coverage in Transifex, Taken from Django's default setting for LANGUAGES
LANGUAGES = (('uk_UA', 'Ukrainian'),) # dont delete!
LOCALE_PATHS = (location('locale'),) # fix Ukraine language bug
# If you set this to False, Django will make some optimizations so as not to load the internationalization machinery
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and calendars according to the current locale
USE_L10N = True
# region 'media and static'
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = location("public/media")
# URL that handles the media served from MEDIA_ROOT. Make sure to use a trailing slash if there is a path component
# (optional in other cases) Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = location('public/static')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_DIRS = (
location('static/'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# endregion
# Make this unique, and don't share it with anybody.
SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
location('templates'),
oscar.OSCAR_MAIN_TEMPLATE_DIR,
],
'OPTIONS': {
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.request',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.contrib.messages.context_processors.messages',
# Oscar specific
'oscar.apps.search.context_processors.search_form',
'oscar.apps.customer.notifications.context_processors.notifications',
'oscar.apps.promotions.context_processors.promotions',
'oscar.apps.checkout.context_processors.checkout',
'oscar.core.context_processors.metadata',
],
'debug': DEBUG,
}
}
]
MIDDLEWARE = [
# 'django.middleware.cache.UpdateCacheMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
# Allow languages to be selected
# 'django.middleware.locale.LocaleMiddleware',
# 'django.middleware.http.ConditionalGetMiddleware',
# 'django.middleware.common.CommonMiddleware',
# Ensure a valid basket is added to the request instance for every request
'oscar.apps.basket.middleware.BasketMiddleware',
# 'django.middleware.cache.FetchFromCacheMiddleware',
]
ROOT_URLCONF = 'urls'
# A sample logging configuration. The only tangible logging performed by this configuration is to send an email to
# the site admins on every HTTP 500 error. See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
},
'simple': {
'format': '[%(asctime)s] %(message)s'
},
},
'root': {
'level': 'DEBUG',
'handlers': ['console'],
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
},
'loggers': {
'oscar': {
'level': 'DEBUG',
'propagate': True,
},
'oscar.catalogue.import': {
'handlers': ['console'],
'level': 'INFO',
'propagate': False,
},
'oscar.alerts': {
'handlers': ['null'],
'level': 'INFO',
'propagate': False,
},
# Django loggers
'django': {
'handlers': ['null'],
'propagate': True,
'level': 'INFO',
},
'django.request': {
'handlers': ['console'],
'level': 'ERROR',
'propagate': True,
},
'django.db.backends': {
'level': 'WARNING',
'propagate': True,
},
'django.security.DisallowedHost': {
'handlers': ['null'],
'propagate': False,
},
# Third party
'raven': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
'sorl.thumbnail': {
'handlers': ['console'],
'propagate': True,
'level': 'INFO',
},
}
}
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.flatpages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'django_extensions',
# 'haystack',
# ====================
# add my apps
# ====================
'apps.utils',
'apps.search2',
'apps.gateway', # For allowing dashboard access
'widget_tweaks',
] + oscar.get_core_apps()
if DEBUG:
INSTALLED_APPS += [
# Debug toolbar + extensions
'debug_toolbar',
'haystack_panel',
# 'debug_toolbar_htmltidy',
]
# DEBUG_TOOLBAR_PANELS = dt_settings.get_panels()+['haystack_panel.panel.HaystackDebugPanel']
# dt_settings.update_toolbar_panels()
# Add Oscar's custom auth backend so users can sign in using their email address
AUTHENTICATION_BACKENDS = (
'oscar.apps.customer.auth_backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'OPTIONS': {
'min_length': 9,
}
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
]
LOGIN_REDIRECT_URL = '/'
APPEND_SLASH = True
# region 'Messages contrib app'
from django.contrib.messages import constants as messages # noqa
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
# endregion
# region 'Haystack settings'
# Here's a sample Haystack config if using Solr (which is recommended)
HAYSTACK_CONNECTIONS = {
'default': {
# 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
# 'URL': 'http://127.0.0.1:8984/solr/%s/' % DEV_APP_NAME,
# 'INCLUDE_SPELLING': True,
},
}
# HAYSTACK_CONNECTIONS = {
# 'default': {
# 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
# 'PATH': 'whoosh',
# 'INCLUDE_SPELLING': True,
# },
# }
# HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
# endregion
# region 'Debug Toolbar'
INTERNAL_IPS = ['127.0.0.1', '::1']
# endregion
# region 'Oscar settings'
from oscar.defaults import * # noqa
OSCAR_SHOP_NAME = 'Світ Комфорту'
# OSCAR_SHOP_TAGLINE = 'купити диван, матрац, ліжко, крісло, стіл, подушку в Тернополі: ціна, продаж'
# OSCAR_HOMEPAGE = reverse_lazy('promotions:home')
OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
OSCAR_ALLOW_ANON_CHECKOUT = True
# Currency
OSCAR_DEFAULT_CURRENCY = 'UAH'
# OSCAR_DEFAULT_CURRENCY = 'грн.'
# OSCAR_CURRENCY_FORMAT = '#,##0'
# Hidden Oscar features, e.g. wishlists or reviews
# OSCAR_HIDDEN_FEATURES = ['reviews', 'wishlists']
# endregion
# region 'Order processing'
# Sample order/line status settings. This is quite simplistic. It's like you'll
# want to override the set_status method on the order object to do more sophisticated things.
OSCAR_INITIAL_ORDER_STATUS = 'Pending'
OSCAR_INITIAL_LINE_STATUS = 'Pending'
# This dict defines the new order statuses than an order can move to
OSCAR_ORDER_STATUS_PIPELINE = {
'Pending': ('Being processed', 'Cancelled',),
'Being processed': ('Complete', 'Cancelled',),
'Cancelled': (),
'Complete': (),
}
# This dict defines the line statuses that will be set when an order's status is changed
OSCAR_ORDER_STATUS_CASCADE = {
'Being processed': 'Being processed',
'Cancelled': 'Cancelled',
'Complete': 'Shipped',
}
# endregion
# region 'LESS/CS
# ========
# We default to using CSS files, rather than the LESS files that generate them.
# If you want to develop Oscar's CSS, then set USE_LESS=True to enable the on-the-fly less processor.
OSCAR_USE_LESS = False
# endregion
# region 'Sentry'
if env('SENTRY_DSN', default=None):
RAVEN_CONFIG = {'dsn': env('SENTRY_DSN', default=None)}
LOGGING['handlers']['sentry'] = {
'level': 'ERROR',
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
}
LOGGING['root']['handlers'].append('sentry')
INSTALLED_APPS.append('raven.contrib.django.raven_compat')
# endregion
# region 'Sorl_Thumbnail'
THUMBNAIL_QUALITY = 100
THUMBNAIL_DEBUG = False
THUMBNAIL_KEY_PREFIX = DEV_APP_NAME
THUMBNAIL_KVSTORE = env('THUMBNAIL_KVSTORE', default='sorl.thumbnail.kvstores.cached_db_kvstore.KVStore')
THUMBNAIL_REDIS_URL = env('THUMBNAIL_REDIS_URL', default=None)
# endregion
# Django 1.6 has switched to JSON serializing for security reasons, but it does not
# serialize Models. We should resolve this by extending the
# django/core/serializers/json.Serializer to have the `dumps` function. Also in tests/config.py
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
# Try and import local settings which can be used to override any of the above.
try:
from settings_local import *
except ImportError:
pass