Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

settings.py 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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. ALLOWED_HOSTS = [
  10. 'latest.oscarcommerce.com',
  11. 'master.oscarcommerce.com',
  12. 'localhost',
  13. '127.0.0.1',
  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. ],
  109. 'OPTIONS': {
  110. 'loaders': [
  111. 'django.template.loaders.filesystem.Loader',
  112. 'django.template.loaders.app_directories.Loader',
  113. ],
  114. 'context_processors': [
  115. 'django.contrib.auth.context_processors.auth',
  116. 'django.template.context_processors.request',
  117. 'django.template.context_processors.debug',
  118. 'django.template.context_processors.i18n',
  119. 'django.template.context_processors.media',
  120. 'django.template.context_processors.static',
  121. 'django.contrib.messages.context_processors.messages',
  122. # Oscar specific
  123. 'oscar.apps.search.context_processors.search_form',
  124. 'oscar.apps.customer.notifications.context_processors.notifications',
  125. 'oscar.apps.checkout.context_processors.checkout',
  126. 'oscar.core.context_processors.metadata',
  127. ],
  128. 'debug': DEBUG,
  129. }
  130. }
  131. ]
  132. MIDDLEWARE = [
  133. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  134. 'django.middleware.security.SecurityMiddleware',
  135. 'whitenoise.middleware.WhiteNoiseMiddleware',
  136. 'django.contrib.sessions.middleware.SessionMiddleware',
  137. 'django.middleware.csrf.CsrfViewMiddleware',
  138. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  139. 'django.contrib.messages.middleware.MessageMiddleware',
  140. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  141. # Allow languages to be selected
  142. 'django.middleware.locale.LocaleMiddleware',
  143. 'django.middleware.http.ConditionalGetMiddleware',
  144. 'django.middleware.common.CommonMiddleware',
  145. # Ensure a valid basket is added to the request instance for every request
  146. 'oscar.apps.basket.middleware.BasketMiddleware',
  147. ]
  148. ROOT_URLCONF = 'urls'
  149. # A sample logging configuration. The only tangible logging
  150. # performed by this configuration is to send an email to
  151. # the site admins on every HTTP 500 error.
  152. # See http://docs.djangoproject.com/en/dev/topics/logging for
  153. # more details on how to customize your logging configuration.
  154. LOGGING = {
  155. 'version': 1,
  156. 'disable_existing_loggers': True,
  157. 'formatters': {
  158. 'verbose': {
  159. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  160. },
  161. 'simple': {
  162. 'format': '[%(asctime)s] %(message)s'
  163. },
  164. },
  165. 'root': {
  166. 'level': 'DEBUG',
  167. 'handlers': ['console'],
  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. },
  180. 'loggers': {
  181. 'oscar': {
  182. 'level': 'DEBUG',
  183. 'propagate': True,
  184. },
  185. 'oscar.catalogue.import': {
  186. 'handlers': ['console'],
  187. 'level': 'INFO',
  188. 'propagate': False,
  189. },
  190. 'oscar.alerts': {
  191. 'handlers': ['null'],
  192. 'level': 'INFO',
  193. 'propagate': False,
  194. },
  195. # Django loggers
  196. 'django': {
  197. 'handlers': ['null'],
  198. 'propagate': True,
  199. 'level': 'INFO',
  200. },
  201. 'django.request': {
  202. 'handlers': ['console'],
  203. 'level': 'ERROR',
  204. 'propagate': True,
  205. },
  206. 'django.db.backends': {
  207. 'level': 'WARNING',
  208. 'propagate': True,
  209. },
  210. 'django.security.DisallowedHost': {
  211. 'handlers': ['null'],
  212. 'propagate': False,
  213. },
  214. # Third party
  215. 'raven': {
  216. 'level': 'DEBUG',
  217. 'handlers': ['console'],
  218. 'propagate': False,
  219. },
  220. 'sorl.thumbnail': {
  221. 'handlers': ['console'],
  222. 'propagate': True,
  223. 'level': 'INFO',
  224. },
  225. }
  226. }
  227. INSTALLED_APPS = [
  228. 'django.contrib.admin',
  229. 'django.contrib.auth',
  230. 'django.contrib.contenttypes',
  231. 'django.contrib.sessions',
  232. 'django.contrib.messages',
  233. 'django.contrib.staticfiles',
  234. 'django.contrib.sites',
  235. 'django.contrib.flatpages',
  236. 'oscar',
  237. 'oscar.apps.analytics',
  238. 'oscar.apps.checkout',
  239. 'oscar.apps.address',
  240. 'oscar.apps.shipping',
  241. 'oscar.apps.catalogue',
  242. 'oscar.apps.catalogue.reviews',
  243. 'oscar.apps.partner',
  244. 'oscar.apps.basket',
  245. 'oscar.apps.payment',
  246. 'oscar.apps.offer',
  247. 'oscar.apps.order',
  248. 'oscar.apps.customer',
  249. 'oscar.apps.search',
  250. 'oscar.apps.voucher',
  251. 'oscar.apps.wishlists',
  252. 'oscar.apps.dashboard',
  253. 'oscar.apps.dashboard.reports',
  254. 'oscar.apps.dashboard.users',
  255. 'oscar.apps.dashboard.orders',
  256. 'oscar.apps.dashboard.catalogue',
  257. 'oscar.apps.dashboard.offers',
  258. 'oscar.apps.dashboard.partners',
  259. 'oscar.apps.dashboard.pages',
  260. 'oscar.apps.dashboard.ranges',
  261. 'oscar.apps.dashboard.reviews',
  262. 'oscar.apps.dashboard.vouchers',
  263. 'oscar.apps.dashboard.communications',
  264. 'oscar.apps.dashboard.shipping',
  265. # 3rd-party apps that Oscar depends on
  266. 'widget_tweaks',
  267. 'haystack',
  268. 'treebeard',
  269. 'sorl.thumbnail',
  270. 'easy_thumbnails',
  271. 'django_tables2',
  272. # Django apps that the sandbox depends on
  273. 'django.contrib.sitemaps',
  274. # 3rd-party apps that the sandbox depends on
  275. 'django_extensions',
  276. 'debug_toolbar',
  277. # For allowing dashboard access
  278. 'apps.gateway',
  279. ]
  280. # Add Oscar's custom auth backend so users can sign in using their email
  281. # address.
  282. AUTHENTICATION_BACKENDS = (
  283. 'oscar.apps.customer.auth_backends.EmailBackend',
  284. 'django.contrib.auth.backends.ModelBackend',
  285. )
  286. AUTH_PASSWORD_VALIDATORS = [
  287. {
  288. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  289. 'OPTIONS': {
  290. 'min_length': 9,
  291. }
  292. },
  293. {
  294. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  295. },
  296. ]
  297. LOGIN_REDIRECT_URL = '/'
  298. APPEND_SLASH = True
  299. # ====================
  300. # Messages contrib app
  301. # ====================
  302. from django.contrib.messages import constants as messages
  303. MESSAGE_TAGS = {
  304. messages.ERROR: 'danger'
  305. }
  306. # Haystack settings
  307. HAYSTACK_CONNECTIONS = {
  308. 'default': {
  309. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  310. 'PATH': location('whoosh_index'),
  311. },
  312. }
  313. # Here's a sample Haystack config if using Solr (which is recommended)
  314. #HAYSTACK_CONNECTIONS = {
  315. # 'default': {
  316. # 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  317. # 'URL': 'http://127.0.0.1:8983/solr/oscar_latest/',
  318. # 'INCLUDE_SPELLING': True
  319. # },
  320. #}
  321. # =============
  322. # Debug Toolbar
  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. # Order processing
  335. # ================
  336. # Sample order/line status settings. This is quite simplistic. It's like you'll
  337. # want to override the set_status method on the order object to do more
  338. # sophisticated things.
  339. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  340. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  341. # This dict defines the new order statuses than an order can move to
  342. OSCAR_ORDER_STATUS_PIPELINE = {
  343. 'Pending': ('Being processed', 'Cancelled',),
  344. 'Being processed': ('Complete', 'Cancelled',),
  345. 'Cancelled': (),
  346. 'Complete': (),
  347. }
  348. # This dict defines the line statuses that will be set when an order's status
  349. # is changed
  350. OSCAR_ORDER_STATUS_CASCADE = {
  351. 'Being processed': 'Being processed',
  352. 'Cancelled': 'Cancelled',
  353. 'Complete': 'Shipped',
  354. }
  355. # LESS/CSS
  356. # ========
  357. # We default to using CSS files, rather than the LESS files that generate them.
  358. # If you want to develop Oscar's CSS, then set OSCAR_USE_LESS=True to enable the
  359. # on-the-fly less processor.
  360. OSCAR_USE_LESS = False
  361. # Sentry
  362. # ======
  363. if env('SENTRY_DSN', default=None):
  364. RAVEN_CONFIG = {'dsn': env('SENTRY_DSN', default=None)}
  365. LOGGING['handlers']['sentry'] = {
  366. 'level': 'ERROR',
  367. 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
  368. }
  369. LOGGING['root']['handlers'].append('sentry')
  370. INSTALLED_APPS.append('raven.contrib.django.raven_compat')
  371. # Sorl
  372. # ====
  373. THUMBNAIL_DEBUG = DEBUG
  374. THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'
  375. THUMBNAIL_KVSTORE = env(
  376. 'THUMBNAIL_KVSTORE',
  377. default='sorl.thumbnail.kvstores.cached_db_kvstore.KVStore')
  378. THUMBNAIL_REDIS_URL = env('THUMBNAIL_REDIS_URL', default=None)
  379. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  380. # serialize Models. We should resolve this by extending the
  381. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  382. # in tests/config.py
  383. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  384. # Try and import local settings which can be used to override any of the above.
  385. try:
  386. from settings_local import *
  387. except ImportError:
  388. pass