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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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. ('en-gb', gettext_noop('British English')),
  55. ('zh-cn', gettext_noop('Simplified Chinese')),
  56. ('nl', gettext_noop('Dutch')),
  57. ('it', gettext_noop('Italian')),
  58. ('pl', gettext_noop('Polish')),
  59. ('ru', gettext_noop('Russian')),
  60. ('sk', gettext_noop('Slovak')),
  61. ('pt-br', gettext_noop('Brazilian Portuguese')),
  62. ('fr', gettext_noop('French')),
  63. ('de', gettext_noop('German')),
  64. ('ko', gettext_noop('Korean')),
  65. ('uk', gettext_noop('Ukrainian')),
  66. ('es', gettext_noop('Spanish')),
  67. ('da', gettext_noop('Danish')),
  68. ('ar', gettext_noop('Arabic')),
  69. ('ca', gettext_noop('Catalan')),
  70. ('cs', gettext_noop('Czech')),
  71. ('el', gettext_noop('Greek')),
  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.middleware.transaction.TransactionMiddleware',
  132. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  133. # Allow languages to be selected
  134. 'django.middleware.locale.LocaleMiddleware',
  135. 'django.middleware.common.CommonMiddleware',
  136. # Ensure a valid basket is added to the request instance for every request
  137. 'oscar.apps.basket.middleware.BasketMiddleware',
  138. # Enable the ProfileMiddleware, then add ?cprofile to any
  139. # URL path to print out profile details
  140. #'oscar.profiling.middleware.ProfileMiddleware',
  141. )
  142. ROOT_URLCONF = 'urls'
  143. # Add another path to Oscar's templates. This allows templates to be
  144. # customised easily.
  145. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  146. TEMPLATE_DIRS = (
  147. location('templates'),
  148. OSCAR_MAIN_TEMPLATE_DIR,
  149. )
  150. # A sample logging configuration. The only tangible logging
  151. # performed by this configuration is to send an email to
  152. # the site admins on every HTTP 500 error.
  153. # See http://docs.djangoproject.com/en/dev/topics/logging for
  154. # more details on how to customize your logging configuration.
  155. LOGGING = {
  156. 'version': 1,
  157. 'disable_existing_loggers': True,
  158. 'formatters': {
  159. 'verbose': {
  160. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  161. },
  162. 'simple': {
  163. 'format': '[%(asctime)s] %(message)s'
  164. },
  165. },
  166. 'filters': {
  167. 'require_debug_false': {
  168. '()': 'django.utils.log.RequireDebugFalse'
  169. }
  170. },
  171. 'handlers': {
  172. 'null': {
  173. 'level': 'DEBUG',
  174. 'class': 'django.utils.log.NullHandler',
  175. },
  176. 'console': {
  177. 'level': 'DEBUG',
  178. 'class': 'logging.StreamHandler',
  179. 'formatter': 'verbose'
  180. },
  181. 'checkout_file': {
  182. 'level': 'INFO',
  183. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  184. 'filename': 'checkout.log',
  185. 'formatter': 'verbose'
  186. },
  187. 'gateway_file': {
  188. 'level': 'INFO',
  189. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  190. 'filename': 'gateway.log',
  191. 'formatter': 'simple'
  192. },
  193. 'error_file': {
  194. 'level': 'INFO',
  195. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  196. 'filename': 'errors.log',
  197. 'formatter': 'verbose'
  198. },
  199. 'sorl_file': {
  200. 'level': 'INFO',
  201. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  202. 'filename': 'sorl.log',
  203. 'formatter': 'verbose'
  204. },
  205. 'mail_admins': {
  206. 'level': 'ERROR',
  207. 'class': 'django.utils.log.AdminEmailHandler',
  208. 'filters': ['require_debug_false'],
  209. },
  210. },
  211. 'loggers': {
  212. # Django loggers
  213. 'django': {
  214. 'handlers': ['null'],
  215. 'propagate': True,
  216. 'level': 'INFO',
  217. },
  218. 'django.request': {
  219. 'handlers': ['mail_admins', 'error_file'],
  220. 'level': 'ERROR',
  221. 'propagate': False,
  222. },
  223. 'django.db.backends': {
  224. 'handlers': ['null'],
  225. 'propagate': False,
  226. 'level': 'DEBUG',
  227. },
  228. # Oscar core loggers
  229. 'oscar.checkout': {
  230. 'handlers': ['console', 'checkout_file'],
  231. 'propagate': False,
  232. 'level': 'INFO',
  233. },
  234. 'oscar.catalogue.import': {
  235. 'handlers': ['console'],
  236. 'propagate': False,
  237. 'level': 'INFO',
  238. },
  239. 'oscar.alerts': {
  240. 'handlers': ['null'],
  241. 'propagate': False,
  242. 'level': 'INFO',
  243. },
  244. # Sandbox logging
  245. 'gateway': {
  246. 'handlers': ['gateway_file'],
  247. 'propagate': True,
  248. 'level': 'INFO',
  249. },
  250. # Third party
  251. 'south': {
  252. 'handlers': ['null'],
  253. 'propagate': True,
  254. 'level': 'INFO',
  255. },
  256. 'sorl.thumbnail': {
  257. 'handlers': ['sorl_file'],
  258. 'propagate': True,
  259. 'level': 'INFO',
  260. },
  261. # Suppress output of this debug toolbar panel
  262. 'template_timings_panel': {
  263. 'handlers': ['null'],
  264. 'level': 'DEBUG',
  265. 'propagate': False,
  266. }
  267. }
  268. }
  269. INSTALLED_APPS = [
  270. 'django.contrib.auth',
  271. 'django.contrib.contenttypes',
  272. 'django.contrib.sessions',
  273. 'django.contrib.sites',
  274. 'django.contrib.messages',
  275. 'django.contrib.admin',
  276. 'django.contrib.flatpages',
  277. 'django.contrib.staticfiles',
  278. 'django.contrib.sitemaps',
  279. 'django_extensions',
  280. # Debug toolbar + extensions
  281. 'debug_toolbar',
  282. 'template_timings_panel',
  283. 'compressor', # Oscar's templates use compressor
  284. 'apps.gateway', # For allowing dashboard access
  285. ]
  286. from oscar import get_core_apps
  287. INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
  288. # As we use the sandbox to create both South migrations and native ones,
  289. # the sandbox needs to work both with Django < 1.7 and 1.7
  290. import django
  291. if django.VERSION < (1, 7):
  292. INSTALLED_APPS.append('south')
  293. # Add Oscar's custom auth backend so users can sign in using their email
  294. # address.
  295. AUTHENTICATION_BACKENDS = (
  296. 'oscar.apps.customer.auth_backends.EmailBackend',
  297. 'django.contrib.auth.backends.ModelBackend',
  298. )
  299. LOGIN_REDIRECT_URL = '/'
  300. APPEND_SLASH = True
  301. # Haystack settings
  302. HAYSTACK_CONNECTIONS = {
  303. 'default': {
  304. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  305. 'PATH': location('whoosh_index'),
  306. },
  307. }
  308. # =============
  309. # Debug Toolbar
  310. # =============
  311. # Implicit setup can often lead to problems with circular imports, so we
  312. # explicitly wire up the toolbar
  313. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  314. DEBUG_TOOLBAR_PANELS = [
  315. 'debug_toolbar.panels.versions.VersionsPanel',
  316. 'debug_toolbar.panels.timer.TimerPanel',
  317. 'debug_toolbar.panels.settings.SettingsPanel',
  318. 'debug_toolbar.panels.headers.HeadersPanel',
  319. 'debug_toolbar.panels.request.RequestPanel',
  320. 'debug_toolbar.panels.sql.SQLPanel',
  321. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  322. 'debug_toolbar.panels.templates.TemplatesPanel',
  323. 'template_timings_panel.panels.TemplateTimings.TemplateTimings',
  324. 'debug_toolbar.panels.cache.CachePanel',
  325. 'debug_toolbar.panels.signals.SignalsPanel',
  326. 'debug_toolbar.panels.logging.LoggingPanel',
  327. 'debug_toolbar.panels.redirects.RedirectsPanel',
  328. ]
  329. INTERNAL_IPS = ['127.0.0.1', '::1']
  330. # ==============
  331. # Oscar settings
  332. # ==============
  333. from oscar.defaults import *
  334. # Meta
  335. # ====
  336. OSCAR_SHOP_TAGLINE = 'Sandbox'
  337. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  338. OSCAR_ALLOW_ANON_CHECKOUT = True
  339. # This is added to each template context by the core context processor. It is
  340. # useful for test/stage/qa sites where you want to show the version of the site
  341. # in the page title.
  342. DISPLAY_VERSION = False
  343. # Order processing
  344. # ================
  345. # Sample order/line status settings. This is quite simplistic. It's like you'll
  346. # want to override the set_status method on the order object to do more
  347. # sophisticated things.
  348. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  349. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  350. # This dict defines the new order statuses than an order can move to
  351. OSCAR_ORDER_STATUS_PIPELINE = {
  352. 'Pending': ('Being processed', 'Cancelled',),
  353. 'Being processed': ('Complete', 'Cancelled',),
  354. 'Cancelled': (),
  355. 'Complete': (),
  356. }
  357. # This dict defines the line statuses that will be set when an order's status
  358. # is changed
  359. OSCAR_ORDER_STATUS_CASCADE = {
  360. 'Being processed': 'Being processed',
  361. 'Cancelled': 'Cancelled',
  362. 'Complete': 'Shipped',
  363. }
  364. # LESS/CSS/statics
  365. # ================
  366. # We default to using CSS files, rather than the LESS files that generate them.
  367. # If you want to develop Oscar's CSS, then set USE_LESS=True and
  368. # COMPRESS_ENABLED=False in your settings_local module and ensure you have
  369. # 'lessc' installed. You can do this by running:
  370. #
  371. # pip install -r requirements_less.txt
  372. #
  373. # which will install node.js and less in your virtualenv.
  374. USE_LESS = False
  375. COMPRESS_ENABLED = True
  376. COMPRESS_PRECOMPILERS = (
  377. ('text/less', 'lessc {infile} {outfile}'),
  378. )
  379. COMPRESS_OFFLINE_CONTEXT = {
  380. 'STATIC_URL': 'STATIC_URL',
  381. 'use_less': USE_LESS,
  382. }
  383. # We do this to work around an issue in compressor where the LESS files are
  384. # compiled but compression isn't enabled. When this happens, the relative URL
  385. # is wrong between the generated CSS file and other assets:
  386. # https://github.com/jezdez/django_compressor/issues/226
  387. COMPRESS_OUTPUT_DIR = 'oscar'
  388. # Logging
  389. # =======
  390. LOG_ROOT = location('logs')
  391. # Ensure log root exists
  392. if not os.path.exists(LOG_ROOT):
  393. os.mkdir(LOG_ROOT)
  394. # Sorl
  395. # ====
  396. THUMBNAIL_DEBUG = True
  397. THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'
  398. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  399. # serialize Models. We should resolve this by extending the
  400. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  401. # in tests/config.py
  402. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  403. # Try and import local settings which can be used to override any of the above.
  404. try:
  405. from settings_local import *
  406. except ImportError:
  407. pass