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

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