Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

settings.py 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. import os
  2. import environ
  3. import oscar
  4. env = environ.Env()
  5. # Path helper
  6. location = lambda x: os.path.join(
  7. os.path.dirname(os.path.realpath(__file__)), x)
  8. DEBUG = env.bool('DEBUG', default=True)
  9. SQL_DEBUG = DEBUG
  10. ALLOWED_HOSTS = [
  11. 'latest.oscarcommerce.com',
  12. 'master.oscarcommerce.com',
  13. 'localhost',
  14. ]
  15. # This is needed for the hosted version of the sandbox
  16. ADMINS = (
  17. ('David Winterbottom', 'david.winterbottom@gmail.com'),
  18. ('Michael van Tellingen', 'michaelvantellingen@gmail.com'),
  19. )
  20. EMAIL_SUBJECT_PREFIX = '[Oscar sandbox] '
  21. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  22. MANAGERS = ADMINS
  23. # Use a Sqlite database by default
  24. DATABASES = {
  25. 'default': {
  26. 'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.sqlite3'),
  27. 'NAME': os.environ.get('DATABASE_NAME', location('db.sqlite')),
  28. 'USER': os.environ.get('DATABASE_USER', None),
  29. 'PASSWORD': os.environ.get('DATABASE_PASSWORD', None),
  30. 'HOST': os.environ.get('DATABASE_HOST', None),
  31. 'PORT': os.environ.get('DATABASE_PORT', None),
  32. 'ATOMIC_REQUESTS': True
  33. }
  34. }
  35. CACHES = {
  36. 'default': env.cache(default='locmemcache://'),
  37. }
  38. # Local time zone for this installation. Choices can be found here:
  39. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  40. # although not all choices may be available on all operating systems.
  41. # On Unix systems, a value of None will cause Django to use the same
  42. # timezone as the operating system.
  43. # If running in a Windows environment this must be set to the same as your
  44. # system time zone.
  45. USE_TZ = True
  46. TIME_ZONE = 'Europe/London'
  47. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
  48. # Language code for this installation. All choices can be found here:
  49. # http://www.i18nguy.com/unicode/language-identifiers.html
  50. LANGUAGE_CODE = 'en-gb'
  51. # Includes all languages that have >50% coverage in Transifex
  52. # Taken from Django's default setting for LANGUAGES
  53. gettext_noop = lambda s: s
  54. LANGUAGES = (
  55. ('ar', gettext_noop('Arabic')),
  56. ('ca', gettext_noop('Catalan')),
  57. ('cs', gettext_noop('Czech')),
  58. ('da', gettext_noop('Danish')),
  59. ('de', gettext_noop('German')),
  60. ('en-gb', gettext_noop('British English')),
  61. ('el', gettext_noop('Greek')),
  62. ('es', gettext_noop('Spanish')),
  63. ('fi', gettext_noop('Finnish')),
  64. ('fr', gettext_noop('French')),
  65. ('it', gettext_noop('Italian')),
  66. ('ko', gettext_noop('Korean')),
  67. ('nl', gettext_noop('Dutch')),
  68. ('pl', gettext_noop('Polish')),
  69. ('pt', gettext_noop('Portuguese')),
  70. ('pt-br', gettext_noop('Brazilian Portuguese')),
  71. ('ro', gettext_noop('Romanian')),
  72. ('ru', gettext_noop('Russian')),
  73. ('sk', gettext_noop('Slovak')),
  74. ('uk', gettext_noop('Ukrainian')),
  75. ('zh-cn', gettext_noop('Simplified Chinese')),
  76. )
  77. SITE_ID = 1
  78. # If you set this to False, Django will make some optimizations so as not
  79. # to load the internationalization machinery.
  80. USE_I18N = True
  81. # If you set this to False, Django will not format dates, numbers and
  82. # calendars according to the current locale
  83. USE_L10N = True
  84. # Absolute path to the directory that holds media.
  85. # Example: "/home/media/media.lawrence.com/"
  86. MEDIA_ROOT = location("public/media")
  87. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  88. # trailing slash if there is a path component (optional in other cases).
  89. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  90. MEDIA_URL = '/media/'
  91. STATIC_URL = '/static/'
  92. STATIC_ROOT = location('public/static')
  93. STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  94. STATICFILES_DIRS = (
  95. location('static/'),
  96. )
  97. STATICFILES_FINDERS = (
  98. 'django.contrib.staticfiles.finders.FileSystemFinder',
  99. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  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. TEMPLATES = [
  104. {
  105. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  106. 'DIRS': [
  107. location('templates'),
  108. oscar.OSCAR_MAIN_TEMPLATE_DIR,
  109. ],
  110. 'OPTIONS': {
  111. 'loaders': [
  112. 'django.template.loaders.filesystem.Loader',
  113. 'django.template.loaders.app_directories.Loader',
  114. 'django.template.loaders.eggs.Loader',
  115. ],
  116. 'context_processors': [
  117. 'django.contrib.auth.context_processors.auth',
  118. 'django.template.context_processors.request',
  119. 'django.template.context_processors.debug',
  120. 'django.template.context_processors.i18n',
  121. 'django.template.context_processors.media',
  122. 'django.template.context_processors.static',
  123. 'django.contrib.messages.context_processors.messages',
  124. # Oscar specific
  125. 'oscar.apps.search.context_processors.search_form',
  126. 'oscar.apps.customer.notifications.context_processors.notifications',
  127. 'oscar.apps.promotions.context_processors.promotions',
  128. 'oscar.apps.checkout.context_processors.checkout',
  129. 'oscar.core.context_processors.metadata',
  130. ],
  131. 'debug': DEBUG,
  132. }
  133. }
  134. ]
  135. MIDDLEWARE = [
  136. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  137. 'django.middleware.security.SecurityMiddleware',
  138. 'whitenoise.middleware.WhiteNoiseMiddleware',
  139. 'django.contrib.sessions.middleware.SessionMiddleware',
  140. 'django.middleware.csrf.CsrfViewMiddleware',
  141. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  142. 'django.contrib.messages.middleware.MessageMiddleware',
  143. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  144. # Allow languages to be selected
  145. 'django.middleware.locale.LocaleMiddleware',
  146. 'django.middleware.http.ConditionalGetMiddleware',
  147. 'django.middleware.common.CommonMiddleware',
  148. # Ensure a valid basket is added to the request instance for every request
  149. 'oscar.apps.basket.middleware.BasketMiddleware',
  150. # Enable the ProfileMiddleware, then add ?cprofile to any
  151. # URL path to print out profile details
  152. #'oscar.profiling.middleware.ProfileMiddleware',
  153. ]
  154. ROOT_URLCONF = 'urls'
  155. # A sample logging configuration. The only tangible logging
  156. # performed by this configuration is to send an email to
  157. # the site admins on every HTTP 500 error.
  158. # See http://docs.djangoproject.com/en/dev/topics/logging for
  159. # more details on how to customize your logging configuration.
  160. LOGGING = {
  161. 'version': 1,
  162. 'disable_existing_loggers': True,
  163. 'formatters': {
  164. 'verbose': {
  165. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  166. },
  167. 'simple': {
  168. 'format': '[%(asctime)s] %(message)s'
  169. },
  170. },
  171. 'root': {
  172. 'level': 'DEBUG',
  173. 'handlers': ['console'],
  174. },
  175. 'handlers': {
  176. 'null': {
  177. 'level': 'DEBUG',
  178. 'class': 'logging.NullHandler',
  179. },
  180. 'console': {
  181. 'level': 'DEBUG',
  182. 'class': 'logging.StreamHandler',
  183. 'formatter': 'simple'
  184. },
  185. },
  186. 'loggers': {
  187. 'oscar': {
  188. 'level': 'DEBUG',
  189. 'propagate': True,
  190. },
  191. 'oscar.catalogue.import': {
  192. 'handlers': ['console'],
  193. 'level': 'INFO',
  194. 'propagate': False,
  195. },
  196. 'oscar.alerts': {
  197. 'handlers': ['null'],
  198. 'level': 'INFO',
  199. 'propagate': False,
  200. },
  201. # Django loggers
  202. 'django': {
  203. 'handlers': ['null'],
  204. 'propagate': True,
  205. 'level': 'INFO',
  206. },
  207. 'django.request': {
  208. 'handlers': ['console'],
  209. 'level': 'ERROR',
  210. 'propagate': True,
  211. },
  212. 'django.db.backends': {
  213. 'level': 'WARNING',
  214. 'propagate': True,
  215. },
  216. # Third party
  217. 'raven': {
  218. 'level': 'DEBUG',
  219. 'handlers': ['console'],
  220. 'propagate': False,
  221. },
  222. 'sorl.thumbnail': {
  223. 'handlers': ['console'],
  224. 'propagate': True,
  225. 'level': 'INFO',
  226. },
  227. }
  228. }
  229. INSTALLED_APPS = [
  230. 'django.contrib.auth',
  231. 'django.contrib.contenttypes',
  232. 'django.contrib.sessions',
  233. 'django.contrib.sites',
  234. 'django.contrib.messages',
  235. 'django.contrib.admin',
  236. 'django.contrib.flatpages',
  237. 'django.contrib.staticfiles',
  238. 'django.contrib.sitemaps',
  239. 'django_extensions',
  240. # Debug toolbar + extensions
  241. 'debug_toolbar',
  242. 'apps.gateway', # For allowing dashboard access
  243. 'widget_tweaks',
  244. ] + oscar.get_core_apps()
  245. # Add Oscar's custom auth backend so users can sign in using their email
  246. # address.
  247. AUTHENTICATION_BACKENDS = (
  248. 'oscar.apps.customer.auth_backends.EmailBackend',
  249. 'django.contrib.auth.backends.ModelBackend',
  250. )
  251. LOGIN_REDIRECT_URL = '/'
  252. APPEND_SLASH = True
  253. # ====================
  254. # Messages contrib app
  255. # ====================
  256. from django.contrib.messages import constants as messages
  257. MESSAGE_TAGS = {
  258. messages.ERROR: 'danger'
  259. }
  260. # Haystack settings
  261. HAYSTACK_CONNECTIONS = {
  262. 'default': {
  263. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  264. 'PATH': location('whoosh_index'),
  265. },
  266. }
  267. # Here's a sample Haystack config if using Solr (which is recommended)
  268. #HAYSTACK_CONNECTIONS = {
  269. # 'default': {
  270. # 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  271. # 'URL': u'http://127.0.0.1:8983/solr/oscar_latest/',
  272. # 'INCLUDE_SPELLING': True
  273. # },
  274. #}
  275. # =============
  276. # Debug Toolbar
  277. # =============
  278. # Implicit setup can often lead to problems with circular imports, so we
  279. # explicitly wire up the toolbar
  280. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  281. DEBUG_TOOLBAR_PANELS = [
  282. 'debug_toolbar.panels.versions.VersionsPanel',
  283. 'debug_toolbar.panels.timer.TimerPanel',
  284. 'debug_toolbar.panels.settings.SettingsPanel',
  285. 'debug_toolbar.panels.headers.HeadersPanel',
  286. 'debug_toolbar.panels.request.RequestPanel',
  287. 'debug_toolbar.panels.sql.SQLPanel',
  288. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  289. 'debug_toolbar.panels.templates.TemplatesPanel',
  290. 'debug_toolbar.panels.cache.CachePanel',
  291. 'debug_toolbar.panels.signals.SignalsPanel',
  292. 'debug_toolbar.panels.logging.LoggingPanel',
  293. 'debug_toolbar.panels.redirects.RedirectsPanel',
  294. ]
  295. INTERNAL_IPS = ['127.0.0.1', '::1']
  296. # ==============
  297. # Oscar settings
  298. # ==============
  299. from oscar.defaults import *
  300. # Meta
  301. # ====
  302. OSCAR_SHOP_TAGLINE = 'Sandbox'
  303. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  304. OSCAR_ALLOW_ANON_CHECKOUT = True
  305. # This is added to each template context by the core context processor. It is
  306. # useful for test/stage/qa sites where you want to show the version of the site
  307. # in the page title.
  308. DISPLAY_VERSION = False
  309. # Order processing
  310. # ================
  311. # Sample order/line status settings. This is quite simplistic. It's like you'll
  312. # want to override the set_status method on the order object to do more
  313. # sophisticated things.
  314. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  315. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  316. # This dict defines the new order statuses than an order can move to
  317. OSCAR_ORDER_STATUS_PIPELINE = {
  318. 'Pending': ('Being processed', 'Cancelled',),
  319. 'Being processed': ('Complete', 'Cancelled',),
  320. 'Cancelled': (),
  321. 'Complete': (),
  322. }
  323. # This dict defines the line statuses that will be set when an order's status
  324. # is changed
  325. OSCAR_ORDER_STATUS_CASCADE = {
  326. 'Being processed': 'Being processed',
  327. 'Cancelled': 'Cancelled',
  328. 'Complete': 'Shipped',
  329. }
  330. # LESS/CSS
  331. # ========
  332. # We default to using CSS files, rather than the LESS files that generate them.
  333. # If you want to develop Oscar's CSS, then set USE_LESS=True to enable the
  334. # on-the-fly less processor.
  335. USE_LESS = False
  336. # Sentry
  337. # ======
  338. if env('SENTRY_DSN', default=None):
  339. RAVEN_CONFIG = {'dsn': env('SENTRY_DSN', default=None)}
  340. LOGGING['handlers']['sentry'] = {
  341. 'level': 'ERROR',
  342. 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
  343. }
  344. LOGGING['root']['handlers'].append('sentry')
  345. INSTALLED_APPS.append('raven.contrib.django.raven_compat')
  346. # Sorl
  347. # ====
  348. THUMBNAIL_DEBUG = True
  349. THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'
  350. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  351. # serialize Models. We should resolve this by extending the
  352. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  353. # in tests/config.py
  354. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  355. # Try and import local settings which can be used to override any of the above.
  356. try:
  357. from settings_local import *
  358. except ImportError:
  359. pass