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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. EMAIL_SUBJECT_PREFIX = '[Oscar US sandbox] '
  10. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  11. # Use a Sqlite database by default
  12. DATABASES = {
  13. 'default': {
  14. 'ENGINE': 'django.db.backends.sqlite3',
  15. 'NAME': location('db.sqlite'),
  16. 'USER': '',
  17. 'PASSWORD': '',
  18. 'HOST': '',
  19. 'PORT': '',
  20. 'ATOMIC_REQUESTS': True
  21. }
  22. }
  23. CACHES = {
  24. 'default': {
  25. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  26. }
  27. }
  28. # Local time zone for this installation. Choices can be found here:
  29. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  30. # although not all choices may be available on all operating systems.
  31. # On Unix systems, a value of None will cause Django to use the same
  32. # timezone as the operating system.
  33. # If running in a Windows environment this must be set to the same as your
  34. # system time zone.
  35. TIME_ZONE = 'Europe/London'
  36. # Language code for this installation. All choices can be found here:
  37. # http://www.i18nguy.com/unicode/language-identifiers.html
  38. LANGUAGE_CODE = 'en-gb'
  39. # Includes all languages that have >50% coverage in Transifex
  40. # Taken from Django's default setting for LANGUAGES
  41. gettext_noop = lambda s: s
  42. LANGUAGES = (
  43. ('en-us', gettext_noop('American English')),
  44. )
  45. SITE_ID = 1
  46. # If you set this to False, Django will make some optimizations so as not
  47. # to load the internationalization machinery.
  48. USE_I18N = True
  49. # If you set this to False, Django will not format dates, numbers and
  50. # calendars according to the current locale
  51. USE_L10N = True
  52. # Absolute path to the directory that holds media.
  53. # Example: "/home/media/media.lawrence.com/"
  54. MEDIA_ROOT = location("public/media")
  55. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  56. # trailing slash if there is a path component (optional in other cases).
  57. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  58. MEDIA_URL = '/media/'
  59. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  60. # trailing slash.
  61. # Examples: "http://foo.com/media/", "/media/".
  62. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  63. STATIC_URL = '/static/'
  64. STATIC_ROOT = location('public/static')
  65. STATICFILES_DIRS = (
  66. location('static/'),
  67. )
  68. STATICFILES_FINDERS = (
  69. 'django.contrib.staticfiles.finders.FileSystemFinder',
  70. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  71. 'compressor.finders.CompressorFinder',
  72. )
  73. # Make this unique, and don't share it with anybody.
  74. SECRET_KEY = '$)a6n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  75. # List of callables that know how to import templates from various sources.
  76. TEMPLATE_LOADERS = (
  77. 'django.template.loaders.filesystem.Loader',
  78. 'django.template.loaders.app_directories.Loader',
  79. # needed by django-treebeard for admin (and potentially other libs)
  80. 'django.template.loaders.eggs.Loader',
  81. )
  82. TEMPLATE_CONTEXT_PROCESSORS = (
  83. "django.contrib.auth.context_processors.auth",
  84. "django.core.context_processors.request",
  85. "django.core.context_processors.debug",
  86. "django.core.context_processors.i18n",
  87. "django.core.context_processors.media",
  88. "django.core.context_processors.static",
  89. "django.contrib.messages.context_processors.messages",
  90. # Oscar specific
  91. 'oscar.apps.search.context_processors.search_form',
  92. 'oscar.apps.promotions.context_processors.promotions',
  93. 'oscar.apps.checkout.context_processors.checkout',
  94. 'oscar.core.context_processors.metadata',
  95. 'oscar.apps.customer.notifications.context_processors.notifications',
  96. )
  97. MIDDLEWARE_CLASSES = (
  98. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  99. 'django.contrib.sessions.middleware.SessionMiddleware',
  100. 'django.middleware.csrf.CsrfViewMiddleware',
  101. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  102. 'django.contrib.messages.middleware.MessageMiddleware',
  103. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  104. # Allow languages to be selected
  105. 'django.middleware.locale.LocaleMiddleware',
  106. 'django.middleware.common.CommonMiddleware',
  107. # Ensure a valid basket is added to the request instance for every request
  108. 'oscar.apps.basket.middleware.BasketMiddleware',
  109. # Enable the ProfileMiddleware, then add ?cprofile to any
  110. # URL path to print out profile details
  111. # 'oscar.profiling.middleware.ProfileMiddleware',
  112. )
  113. ROOT_URLCONF = 'urls'
  114. # Add another path to Oscar's templates. This allows templates to be
  115. # customised easily.
  116. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  117. TEMPLATE_DIRS = (
  118. location('templates'),
  119. OSCAR_MAIN_TEMPLATE_DIR,
  120. )
  121. # A sample logging configuration. The only tangible logging
  122. # performed by this configuration is to send an email to
  123. # the site admins on every HTTP 500 error.
  124. # See http://docs.djangoproject.com/en/dev/topics/logging for
  125. # more details on how to customize your logging configuration.
  126. LOGGING = {
  127. 'version': 1,
  128. 'disable_existing_loggers': True,
  129. 'formatters': {
  130. 'verbose': {
  131. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  132. },
  133. 'simple': {
  134. 'format': '[%(asctime)s] %(message)s'
  135. },
  136. },
  137. 'filters': {
  138. 'require_debug_false': {
  139. '()': 'django.utils.log.RequireDebugFalse'
  140. }
  141. },
  142. 'handlers': {
  143. 'null': {
  144. 'level': 'DEBUG',
  145. 'class': 'django.utils.log.NullHandler',
  146. },
  147. 'console': {
  148. 'level': 'DEBUG',
  149. 'class': 'logging.StreamHandler',
  150. 'formatter': 'verbose'
  151. },
  152. 'checkout_file': {
  153. 'level': 'INFO',
  154. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  155. 'filename': 'checkout.log',
  156. 'formatter': 'verbose'
  157. },
  158. 'gateway_file': {
  159. 'level': 'INFO',
  160. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  161. 'filename': 'gateway.log',
  162. 'formatter': 'simple'
  163. },
  164. 'error_file': {
  165. 'level': 'INFO',
  166. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  167. 'filename': 'errors.log',
  168. 'formatter': 'verbose'
  169. },
  170. 'sorl_file': {
  171. 'level': 'INFO',
  172. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  173. 'filename': 'sorl.log',
  174. 'formatter': 'verbose'
  175. },
  176. 'mail_admins': {
  177. 'level': 'ERROR',
  178. 'class': 'django.utils.log.AdminEmailHandler',
  179. 'filters': ['require_debug_false'],
  180. },
  181. },
  182. 'loggers': {
  183. # Django loggers
  184. 'django': {
  185. 'handlers': ['null'],
  186. 'propagate': True,
  187. 'level': 'INFO',
  188. },
  189. 'django.request': {
  190. 'handlers': ['mail_admins', 'error_file'],
  191. 'level': 'ERROR',
  192. 'propagate': False,
  193. },
  194. 'django.db.backends': {
  195. 'handlers': ['null'],
  196. 'propagate': False,
  197. 'level': 'DEBUG',
  198. },
  199. # Oscar core loggers
  200. 'oscar.checkout': {
  201. 'handlers': ['console', 'checkout_file'],
  202. 'propagate': False,
  203. 'level': 'INFO',
  204. },
  205. 'oscar.catalogue.import': {
  206. 'handlers': ['console'],
  207. 'propagate': False,
  208. 'level': 'INFO',
  209. },
  210. 'oscar.alerts': {
  211. 'handlers': ['null'],
  212. 'propagate': False,
  213. 'level': 'INFO',
  214. },
  215. # Sandbox logging
  216. 'gateway': {
  217. 'handlers': ['gateway_file'],
  218. 'propagate': True,
  219. 'level': 'INFO',
  220. },
  221. # Third party
  222. 'sorl.thumbnail': {
  223. 'handlers': ['sorl_file'],
  224. 'propagate': True,
  225. 'level': 'INFO',
  226. },
  227. # Suppress output of this debug toolbar panel
  228. 'template_timings_panel': {
  229. 'handlers': ['null'],
  230. 'level': 'DEBUG',
  231. 'propagate': False,
  232. }
  233. }
  234. }
  235. INSTALLED_APPS = [
  236. 'django.contrib.auth',
  237. 'django.contrib.contenttypes',
  238. 'django.contrib.sessions',
  239. 'django.contrib.sites',
  240. 'django.contrib.messages',
  241. 'django.contrib.admin',
  242. 'django.contrib.flatpages',
  243. 'django.contrib.staticfiles',
  244. 'django.contrib.sitemaps',
  245. 'django_extensions',
  246. # Debug toolbar + extensions
  247. 'debug_toolbar',
  248. 'template_timings_panel',
  249. 'compressor', # Oscar's templates use compressor
  250. 'widget_tweaks',
  251. ]
  252. from oscar import get_core_apps
  253. INSTALLED_APPS = INSTALLED_APPS + get_core_apps(
  254. ['apps.partner', 'apps.checkout', 'apps.shipping'])
  255. # Add Oscar's custom auth backend so users can sign in using their email
  256. # address.
  257. AUTHENTICATION_BACKENDS = (
  258. 'oscar.apps.customer.auth_backends.EmailBackend',
  259. 'django.contrib.auth.backends.ModelBackend',
  260. )
  261. LOGIN_REDIRECT_URL = '/'
  262. APPEND_SLASH = True
  263. # Haystack settings
  264. HAYSTACK_CONNECTIONS = {
  265. 'default': {
  266. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  267. 'PATH': location('whoosh_index'),
  268. },
  269. }
  270. # =============
  271. # Debug Toolbar
  272. # =============
  273. # Implicit setup can often lead to problems with circular imports, so we
  274. # explicitly wire up the toolbar
  275. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  276. DEBUG_TOOLBAR_PANELS = [
  277. 'debug_toolbar.panels.versions.VersionsPanel',
  278. 'debug_toolbar.panels.timer.TimerPanel',
  279. 'debug_toolbar.panels.settings.SettingsPanel',
  280. 'debug_toolbar.panels.headers.HeadersPanel',
  281. 'debug_toolbar.panels.request.RequestPanel',
  282. 'debug_toolbar.panels.sql.SQLPanel',
  283. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  284. 'debug_toolbar.panels.templates.TemplatesPanel',
  285. 'template_timings_panel.panels.TemplateTimings.TemplateTimings',
  286. 'debug_toolbar.panels.cache.CachePanel',
  287. 'debug_toolbar.panels.signals.SignalsPanel',
  288. 'debug_toolbar.panels.logging.LoggingPanel',
  289. 'debug_toolbar.panels.redirects.RedirectsPanel',
  290. ]
  291. INTERNAL_IPS = ['127.0.0.1', '::1']
  292. # ==============
  293. # Oscar settings
  294. # ==============
  295. from oscar.defaults import * # noqa
  296. # Meta
  297. # ====
  298. OSCAR_SHOP_TAGLINE = 'US Sandbox'
  299. OSCAR_DEFAULT_CURRENCY = 'USD'
  300. OSCAR_ALLOW_ANON_CHECKOUT = True
  301. # LESS/CSS/statics
  302. # ================
  303. # We default to using CSS files, rather than the LESS files that generate them.
  304. # If you want to develop Oscar's CSS, then set USE_LESS=True and
  305. # COMPRESS_ENABLED=False in your settings_local module and ensure you have
  306. # 'lessc' installed.
  307. USE_LESS = False
  308. COMPRESS_ENABLED = True
  309. COMPRESS_PRECOMPILERS = (
  310. ('text/less', 'lessc {infile} {outfile}'),
  311. )
  312. COMPRESS_OFFLINE_CONTEXT = {
  313. 'STATIC_URL': 'STATIC_URL',
  314. 'use_less': USE_LESS,
  315. }
  316. # We do this to work around an issue in compressor where the LESS files are
  317. # compiled but compression isn't enabled. When this happens, the relative URL
  318. # is wrong between the generated CSS file and other assets:
  319. # https://github.com/jezdez/django_compressor/issues/226
  320. COMPRESS_OUTPUT_DIR = 'oscar'
  321. # Logging
  322. # =======
  323. LOG_ROOT = location('logs')
  324. # Ensure log root exists
  325. if not os.path.exists(LOG_ROOT):
  326. os.mkdir(LOG_ROOT)
  327. # Sorl
  328. # ====
  329. THUMBNAIL_DEBUG = True
  330. THUMBNAIL_KEY_PREFIX = 'oscar-us-sandbox'
  331. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  332. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
  333. # Try and import local settings which can be used to override any of the above.
  334. try:
  335. from settings_local import * # noqa
  336. except ImportError:
  337. pass