You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.py 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. import os
  2. # Path helper
  3. location = lambda x: os.path.join(
  4. os.path.dirname(os.path.realpath(__file__)), x)
  5. USE_TZ = True
  6. DEBUG = True
  7. TEMPLATE_DEBUG = True
  8. SQL_DEBUG = True
  9. ALLOWED_HOSTS = ['latest.oscarcommerce.com',
  10. 'sandbox.oscar.tangentlabs.co.uk',
  11. 'master.oscarcommerce.com']
  12. # This is needed for the hosted version of the sandbox
  13. ADMINS = (
  14. ('David Winterbottom', 'david.winterbottom@tangentlabs.co.uk'),
  15. )
  16. EMAIL_SUBJECT_PREFIX = '[Oscar sandbox] '
  17. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  18. MANAGERS = ADMINS
  19. # Use a Sqlite database by default
  20. DATABASES = {
  21. 'default': {
  22. 'ENGINE': 'django.db.backends.sqlite3',
  23. 'NAME': location('db.sqlite'),
  24. 'USER': '',
  25. 'PASSWORD': '',
  26. 'HOST': '',
  27. 'PORT': '',
  28. 'ATOMIC_REQUESTS': True
  29. }
  30. }
  31. CACHES = {
  32. 'default': {
  33. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  34. }
  35. }
  36. # Prevent Django 1.7+ from showing a warning regarding a changed default test
  37. # runner. The Oscar test suite is run with nose, so it does not matter.
  38. SILENCED_SYSTEM_CHECKS = ['1_6.W001', ]
  39. # Local time zone for this installation. Choices can be found here:
  40. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  41. # although not all choices may be available on all operating systems.
  42. # On Unix systems, a value of None will cause Django to use the same
  43. # timezone as the operating system.
  44. # If running in a Windows environment this must be set to the same as your
  45. # system time zone.
  46. TIME_ZONE = 'Europe/London'
  47. # Language code for this installation. All choices can be found here:
  48. # http://www.i18nguy.com/unicode/language-identifiers.html
  49. LANGUAGE_CODE = 'en-gb'
  50. # Includes all languages that have >50% coverage in Transifex
  51. # Taken from Django's default setting for LANGUAGES
  52. gettext_noop = lambda s: s
  53. LANGUAGES = (
  54. ('ar', gettext_noop('Arabic')),
  55. ('ca', gettext_noop('Catalan')),
  56. ('cs', gettext_noop('Czech')),
  57. ('da', gettext_noop('Danish')),
  58. ('de', gettext_noop('German')),
  59. ('en-gb', gettext_noop('British English')),
  60. ('el', gettext_noop('Greek')),
  61. ('es', gettext_noop('Spanish')),
  62. ('fi', gettext_noop('Finnish')),
  63. ('fr', gettext_noop('French')),
  64. ('it', gettext_noop('Italian')),
  65. ('ko', gettext_noop('Korean')),
  66. ('nl', gettext_noop('Dutch')),
  67. ('pl', gettext_noop('Polish')),
  68. ('pt', gettext_noop('Portuguese')),
  69. ('pt-br', gettext_noop('Brazilian Portuguese')),
  70. ('ro', gettext_noop('Romanian')),
  71. ('ru', gettext_noop('Russian')),
  72. ('sk', gettext_noop('Slovak')),
  73. ('uk', gettext_noop('Ukrainian')),
  74. ('zh-cn', gettext_noop('Simplified Chinese')),
  75. )
  76. SITE_ID = 1
  77. # If you set this to False, Django will make some optimizations so as not
  78. # to load the internationalization machinery.
  79. USE_I18N = True
  80. # If you set this to False, Django will not format dates, numbers and
  81. # calendars according to the current locale
  82. USE_L10N = True
  83. # Absolute path to the directory that holds media.
  84. # Example: "/home/media/media.lawrence.com/"
  85. MEDIA_ROOT = location("public/media")
  86. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  87. # trailing slash if there is a path component (optional in other cases).
  88. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  89. MEDIA_URL = '/media/'
  90. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  91. # trailing slash.
  92. # Examples: "http://foo.com/media/", "/media/".
  93. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  94. STATIC_URL = '/static/'
  95. STATIC_ROOT = location('public/static')
  96. STATICFILES_DIRS = (
  97. location('static/'),
  98. )
  99. STATICFILES_FINDERS = (
  100. 'django.contrib.staticfiles.finders.FileSystemFinder',
  101. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  102. 'compressor.finders.CompressorFinder',
  103. )
  104. # Make this unique, and don't share it with anybody.
  105. SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  106. # List of callables that know how to import templates from various sources.
  107. TEMPLATE_LOADERS = (
  108. 'django.template.loaders.filesystem.Loader',
  109. 'django.template.loaders.app_directories.Loader',
  110. # needed by django-treebeard for admin (and potentially other libs)
  111. 'django.template.loaders.eggs.Loader',
  112. )
  113. TEMPLATE_CONTEXT_PROCESSORS = (
  114. "django.contrib.auth.context_processors.auth",
  115. "django.core.context_processors.request",
  116. "django.core.context_processors.debug",
  117. "django.core.context_processors.i18n",
  118. "django.core.context_processors.media",
  119. "django.core.context_processors.static",
  120. "django.contrib.messages.context_processors.messages",
  121. # Oscar specific
  122. 'oscar.apps.search.context_processors.search_form',
  123. 'oscar.apps.promotions.context_processors.promotions',
  124. 'oscar.apps.checkout.context_processors.checkout',
  125. 'oscar.core.context_processors.metadata',
  126. 'oscar.apps.customer.notifications.context_processors.notifications',
  127. )
  128. MIDDLEWARE_CLASSES = (
  129. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  130. 'django.contrib.sessions.middleware.SessionMiddleware',
  131. 'django.middleware.csrf.CsrfViewMiddleware',
  132. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  133. 'django.contrib.messages.middleware.MessageMiddleware',
  134. 'django.middleware.transaction.TransactionMiddleware',
  135. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  136. # Allow languages to be selected
  137. 'django.middleware.locale.LocaleMiddleware',
  138. 'django.middleware.common.CommonMiddleware',
  139. # Ensure a valid basket is added to the request instance for every request
  140. 'oscar.apps.basket.middleware.BasketMiddleware',
  141. # Enable the ProfileMiddleware, then add ?cprofile to any
  142. # URL path to print out profile details
  143. #'oscar.profiling.middleware.ProfileMiddleware',
  144. )
  145. ROOT_URLCONF = 'urls'
  146. # Add another path to Oscar's templates. This allows templates to be
  147. # customised easily.
  148. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  149. TEMPLATE_DIRS = (
  150. location('templates'),
  151. OSCAR_MAIN_TEMPLATE_DIR,
  152. )
  153. # A sample logging configuration. The only tangible logging
  154. # performed by this configuration is to send an email to
  155. # the site admins on every HTTP 500 error.
  156. # See http://docs.djangoproject.com/en/dev/topics/logging for
  157. # more details on how to customize your logging configuration.
  158. LOGGING = {
  159. 'version': 1,
  160. 'disable_existing_loggers': True,
  161. 'formatters': {
  162. 'verbose': {
  163. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  164. },
  165. 'simple': {
  166. 'format': '[%(asctime)s] %(message)s'
  167. },
  168. },
  169. 'filters': {
  170. 'require_debug_false': {
  171. '()': 'django.utils.log.RequireDebugFalse'
  172. }
  173. },
  174. 'handlers': {
  175. 'null': {
  176. 'level': 'DEBUG',
  177. 'class': 'django.utils.log.NullHandler',
  178. },
  179. 'console': {
  180. 'level': 'DEBUG',
  181. 'class': 'logging.StreamHandler',
  182. 'formatter': 'simple'
  183. },
  184. 'checkout_file': {
  185. 'level': 'INFO',
  186. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  187. 'filename': 'checkout.log',
  188. 'formatter': 'verbose'
  189. },
  190. 'gateway_file': {
  191. 'level': 'INFO',
  192. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  193. 'filename': 'gateway.log',
  194. 'formatter': 'simple'
  195. },
  196. 'error_file': {
  197. 'level': 'INFO',
  198. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  199. 'filename': 'errors.log',
  200. 'formatter': 'verbose'
  201. },
  202. 'sorl_file': {
  203. 'level': 'INFO',
  204. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  205. 'filename': 'sorl.log',
  206. 'formatter': 'verbose'
  207. },
  208. 'mail_admins': {
  209. 'level': 'ERROR',
  210. 'class': 'django.utils.log.AdminEmailHandler',
  211. 'filters': ['require_debug_false'],
  212. },
  213. },
  214. 'loggers': {
  215. # Django loggers
  216. 'django': {
  217. 'handlers': ['null'],
  218. 'propagate': True,
  219. 'level': 'INFO',
  220. },
  221. 'django.request': {
  222. 'handlers': ['mail_admins', 'error_file'],
  223. 'level': 'ERROR',
  224. 'propagate': False,
  225. },
  226. 'django.db.backends': {
  227. 'handlers': ['null'],
  228. 'propagate': False,
  229. 'level': 'DEBUG',
  230. },
  231. # Oscar core loggers
  232. 'oscar.checkout': {
  233. 'handlers': ['console', 'checkout_file'],
  234. 'propagate': False,
  235. 'level': 'INFO',
  236. },
  237. 'oscar.catalogue.import': {
  238. 'handlers': ['console'],
  239. 'propagate': False,
  240. 'level': 'INFO',
  241. },
  242. 'oscar.alerts': {
  243. 'handlers': ['null'],
  244. 'propagate': False,
  245. 'level': 'INFO',
  246. },
  247. # Sandbox logging
  248. 'gateway': {
  249. 'handlers': ['gateway_file'],
  250. 'propagate': True,
  251. 'level': 'INFO',
  252. },
  253. # Third party
  254. 'south': {
  255. 'handlers': ['null'],
  256. 'propagate': True,
  257. 'level': 'INFO',
  258. },
  259. 'sorl.thumbnail': {
  260. 'handlers': ['sorl_file'],
  261. 'propagate': True,
  262. 'level': 'INFO',
  263. },
  264. # Suppress output of this debug toolbar panel
  265. 'template_timings_panel': {
  266. 'handlers': ['null'],
  267. 'level': 'DEBUG',
  268. 'propagate': False,
  269. }
  270. }
  271. }
  272. INSTALLED_APPS = [
  273. 'django.contrib.auth',
  274. 'django.contrib.contenttypes',
  275. 'django.contrib.sessions',
  276. 'django.contrib.sites',
  277. 'django.contrib.messages',
  278. 'django.contrib.admin',
  279. 'django.contrib.flatpages',
  280. 'django.contrib.staticfiles',
  281. 'django.contrib.sitemaps',
  282. 'django_extensions',
  283. # Debug toolbar + extensions
  284. 'debug_toolbar',
  285. 'template_timings_panel',
  286. 'compressor', # Oscar's templates use compressor
  287. 'apps.gateway', # For allowing dashboard access
  288. ]
  289. from oscar import get_core_apps
  290. INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
  291. # As we use the sandbox to create both South migrations and native ones,
  292. # the sandbox needs to work both with Django < 1.7 and 1.7
  293. import django
  294. if django.VERSION < (1, 7):
  295. INSTALLED_APPS.append('south')
  296. # Add Oscar's custom auth backend so users can sign in using their email
  297. # address.
  298. AUTHENTICATION_BACKENDS = (
  299. 'oscar.apps.customer.auth_backends.EmailBackend',
  300. 'django.contrib.auth.backends.ModelBackend',
  301. )
  302. LOGIN_REDIRECT_URL = '/'
  303. APPEND_SLASH = True
  304. # Haystack settings
  305. HAYSTACK_CONNECTIONS = {
  306. 'default': {
  307. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  308. 'PATH': location('whoosh_index'),
  309. },
  310. }
  311. # Here's a sample Haystack config if using Solr (which is recommended)
  312. #HAYSTACK_CONNECTIONS = {
  313. # 'default': {
  314. # 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  315. # 'URL': u'http://127.0.0.1:8983/solr/oscar_latest/',
  316. # 'INCLUDE_SPELLING': True
  317. # },
  318. #}
  319. # =============
  320. # Debug Toolbar
  321. # =============
  322. # Implicit setup can often lead to problems with circular imports, so we
  323. # explicitly wire up the toolbar
  324. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  325. DEBUG_TOOLBAR_PANELS = [
  326. 'debug_toolbar.panels.versions.VersionsPanel',
  327. 'debug_toolbar.panels.timer.TimerPanel',
  328. 'debug_toolbar.panels.settings.SettingsPanel',
  329. 'debug_toolbar.panels.headers.HeadersPanel',
  330. 'debug_toolbar.panels.request.RequestPanel',
  331. 'debug_toolbar.panels.sql.SQLPanel',
  332. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  333. 'debug_toolbar.panels.templates.TemplatesPanel',
  334. 'template_timings_panel.panels.TemplateTimings.TemplateTimings',
  335. 'debug_toolbar.panels.cache.CachePanel',
  336. 'debug_toolbar.panels.signals.SignalsPanel',
  337. 'debug_toolbar.panels.logging.LoggingPanel',
  338. 'debug_toolbar.panels.redirects.RedirectsPanel',
  339. ]
  340. INTERNAL_IPS = ['127.0.0.1', '::1']
  341. # ==============
  342. # Oscar settings
  343. # ==============
  344. from oscar.defaults import *
  345. # Meta
  346. # ====
  347. OSCAR_SHOP_TAGLINE = 'Sandbox'
  348. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  349. OSCAR_ALLOW_ANON_CHECKOUT = True
  350. # This is added to each template context by the core context processor. It is
  351. # useful for test/stage/qa sites where you want to show the version of the site
  352. # in the page title.
  353. DISPLAY_VERSION = False
  354. # Order processing
  355. # ================
  356. # Sample order/line status settings. This is quite simplistic. It's like you'll
  357. # want to override the set_status method on the order object to do more
  358. # sophisticated things.
  359. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  360. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  361. # This dict defines the new order statuses than an order can move to
  362. OSCAR_ORDER_STATUS_PIPELINE = {
  363. 'Pending': ('Being processed', 'Cancelled',),
  364. 'Being processed': ('Complete', 'Cancelled',),
  365. 'Cancelled': (),
  366. 'Complete': (),
  367. }
  368. # This dict defines the line statuses that will be set when an order's status
  369. # is changed
  370. OSCAR_ORDER_STATUS_CASCADE = {
  371. 'Being processed': 'Being processed',
  372. 'Cancelled': 'Cancelled',
  373. 'Complete': 'Shipped',
  374. }
  375. # LESS/CSS/statics
  376. # ================
  377. # We default to using CSS files, rather than the LESS files that generate them.
  378. # If you want to develop Oscar's CSS, then set USE_LESS=True and
  379. # COMPRESS_ENABLED=False in your settings_local module and ensure you have
  380. # 'lessc' installed. You can do this by running:
  381. #
  382. # pip install -r requirements_less.txt
  383. #
  384. # which will install node.js and less in your virtualenv.
  385. USE_LESS = False
  386. COMPRESS_ENABLED = True
  387. COMPRESS_PRECOMPILERS = (
  388. ('text/less', 'lessc {infile} {outfile}'),
  389. )
  390. COMPRESS_OFFLINE_CONTEXT = {
  391. 'STATIC_URL': 'STATIC_URL',
  392. 'use_less': USE_LESS,
  393. }
  394. # We do this to work around an issue in compressor where the LESS files are
  395. # compiled but compression isn't enabled. When this happens, the relative URL
  396. # is wrong between the generated CSS file and other assets:
  397. # https://github.com/jezdez/django_compressor/issues/226
  398. COMPRESS_OUTPUT_DIR = 'oscar'
  399. # Logging
  400. # =======
  401. LOG_ROOT = location('logs')
  402. # Ensure log root exists
  403. if not os.path.exists(LOG_ROOT):
  404. os.mkdir(LOG_ROOT)
  405. # Sorl
  406. # ====
  407. THUMBNAIL_DEBUG = True
  408. THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'
  409. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  410. # serialize Models. We should resolve this by extending the
  411. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  412. # in tests/config.py
  413. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  414. # Try and import local settings which can be used to override any of the above.
  415. try:
  416. from settings_local import *
  417. except ImportError:
  418. pass