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 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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. )
  100. # Make this unique, and don't share it with anybody.
  101. SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  102. # List of callables that know how to import templates from various sources.
  103. TEMPLATE_LOADERS = (
  104. 'django.template.loaders.filesystem.Loader',
  105. 'django.template.loaders.app_directories.Loader',
  106. # needed by django-treebeard for admin (and potentially other libs)
  107. 'django.template.loaders.eggs.Loader',
  108. )
  109. TEMPLATE_CONTEXT_PROCESSORS = (
  110. "django.contrib.auth.context_processors.auth",
  111. "django.core.context_processors.request",
  112. "django.core.context_processors.debug",
  113. "django.core.context_processors.i18n",
  114. "django.core.context_processors.media",
  115. "django.core.context_processors.static",
  116. "django.contrib.messages.context_processors.messages",
  117. # Oscar specific
  118. 'oscar.apps.search.context_processors.search_form',
  119. 'oscar.apps.promotions.context_processors.promotions',
  120. 'oscar.apps.checkout.context_processors.checkout',
  121. 'oscar.core.context_processors.metadata',
  122. 'oscar.apps.customer.notifications.context_processors.notifications',
  123. )
  124. MIDDLEWARE_CLASSES = (
  125. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  126. 'django.contrib.sessions.middleware.SessionMiddleware',
  127. 'django.middleware.csrf.CsrfViewMiddleware',
  128. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  129. 'django.contrib.messages.middleware.MessageMiddleware',
  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': 'logging.NullHandler',
  173. },
  174. 'console': {
  175. 'level': 'DEBUG',
  176. 'class': 'logging.StreamHandler',
  177. 'formatter': 'simple'
  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. 'sorl.thumbnail': {
  250. 'handlers': ['sorl_file'],
  251. 'propagate': True,
  252. 'level': 'INFO',
  253. },
  254. }
  255. }
  256. INSTALLED_APPS = [
  257. 'django.contrib.auth',
  258. 'django.contrib.contenttypes',
  259. 'django.contrib.sessions',
  260. 'django.contrib.sites',
  261. 'django.contrib.messages',
  262. 'django.contrib.admin',
  263. 'django.contrib.flatpages',
  264. 'django.contrib.staticfiles',
  265. 'django.contrib.sitemaps',
  266. 'django_extensions',
  267. # Debug toolbar + extensions
  268. 'debug_toolbar',
  269. 'apps.gateway', # For allowing dashboard access
  270. 'widget_tweaks',
  271. ]
  272. from oscar import get_core_apps
  273. INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
  274. # Add Oscar's custom auth backend so users can sign in using their email
  275. # address.
  276. AUTHENTICATION_BACKENDS = (
  277. 'oscar.apps.customer.auth_backends.EmailBackend',
  278. 'django.contrib.auth.backends.ModelBackend',
  279. )
  280. LOGIN_REDIRECT_URL = '/'
  281. APPEND_SLASH = True
  282. # ====================
  283. # Messages contrib app
  284. # ====================
  285. from django.contrib.messages import constants as messages
  286. MESSAGE_TAGS = {
  287. messages.ERROR: 'danger'
  288. }
  289. # Haystack settings
  290. HAYSTACK_CONNECTIONS = {
  291. 'default': {
  292. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  293. 'PATH': location('whoosh_index'),
  294. },
  295. }
  296. # Here's a sample Haystack config if using Solr (which is recommended)
  297. #HAYSTACK_CONNECTIONS = {
  298. # 'default': {
  299. # 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  300. # 'URL': u'http://127.0.0.1:8983/solr/oscar_latest/',
  301. # 'INCLUDE_SPELLING': True
  302. # },
  303. #}
  304. # =============
  305. # Debug Toolbar
  306. # =============
  307. # Implicit setup can often lead to problems with circular imports, so we
  308. # explicitly wire up the toolbar
  309. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  310. DEBUG_TOOLBAR_PANELS = [
  311. 'debug_toolbar.panels.versions.VersionsPanel',
  312. 'debug_toolbar.panels.timer.TimerPanel',
  313. 'debug_toolbar.panels.settings.SettingsPanel',
  314. 'debug_toolbar.panels.headers.HeadersPanel',
  315. 'debug_toolbar.panels.request.RequestPanel',
  316. 'debug_toolbar.panels.sql.SQLPanel',
  317. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  318. 'debug_toolbar.panels.templates.TemplatesPanel',
  319. 'debug_toolbar.panels.cache.CachePanel',
  320. 'debug_toolbar.panels.signals.SignalsPanel',
  321. 'debug_toolbar.panels.logging.LoggingPanel',
  322. 'debug_toolbar.panels.redirects.RedirectsPanel',
  323. ]
  324. INTERNAL_IPS = ['127.0.0.1', '::1']
  325. # ==============
  326. # Oscar settings
  327. # ==============
  328. from oscar.defaults import *
  329. # Meta
  330. # ====
  331. OSCAR_SHOP_TAGLINE = 'Sandbox'
  332. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  333. OSCAR_ALLOW_ANON_CHECKOUT = True
  334. # This is added to each template context by the core context processor. It is
  335. # useful for test/stage/qa sites where you want to show the version of the site
  336. # in the page title.
  337. DISPLAY_VERSION = False
  338. # Order processing
  339. # ================
  340. # Sample order/line status settings. This is quite simplistic. It's like you'll
  341. # want to override the set_status method on the order object to do more
  342. # sophisticated things.
  343. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  344. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  345. # This dict defines the new order statuses than an order can move to
  346. OSCAR_ORDER_STATUS_PIPELINE = {
  347. 'Pending': ('Being processed', 'Cancelled',),
  348. 'Being processed': ('Complete', 'Cancelled',),
  349. 'Cancelled': (),
  350. 'Complete': (),
  351. }
  352. # This dict defines the line statuses that will be set when an order's status
  353. # is changed
  354. OSCAR_ORDER_STATUS_CASCADE = {
  355. 'Being processed': 'Being processed',
  356. 'Cancelled': 'Cancelled',
  357. 'Complete': 'Shipped',
  358. }
  359. # LESS/CSS
  360. # ========
  361. # We default to using CSS files, rather than the LESS files that generate them.
  362. # If you want to develop Oscar's CSS, then set USE_LESS=True to enable the
  363. # on-the-fly less processor.
  364. USE_LESS = False
  365. # Logging
  366. # =======
  367. LOG_ROOT = location('logs')
  368. # Ensure log root exists
  369. if not os.path.exists(LOG_ROOT):
  370. os.mkdir(LOG_ROOT)
  371. # Sorl
  372. # ====
  373. THUMBNAIL_DEBUG = True
  374. THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'
  375. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  376. # serialize Models. We should resolve this by extending the
  377. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  378. # in tests/config.py
  379. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  380. # Try and import local settings which can be used to override any of the above.
  381. try:
  382. from settings_local import *
  383. except ImportError:
  384. pass