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

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