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

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