Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

settings.py 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. import os
  2. # Path helper
  3. PROJECT_DIR = os.path.dirname(__file__)
  4. location = lambda x: os.path.join(
  5. os.path.dirname(os.path.realpath(__file__)), x)
  6. USE_TZ = True
  7. DEBUG = True
  8. TEMPLATE_DEBUG = True
  9. SQL_DEBUG = True
  10. SEND_BROKEN_LINK_EMAILS = False
  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. # This should match the locale folders in oscar/locale
  49. LANGUAGES = (
  50. ('en-gb', 'English'),
  51. ('da', 'Danish'),
  52. ('de', 'German'),
  53. ('el', 'Greek'),
  54. ('en', 'English'),
  55. ('es', 'Spanish'),
  56. ('fr', 'French'),
  57. ('it', 'Italian'),
  58. ('ja', 'Japanese'),
  59. ('pl', 'Polish'),
  60. ('pt', 'Portugese'),
  61. ('ru', 'Russian'),
  62. ('sk', 'Slovakian'),
  63. )
  64. ROSETTA_STORAGE_CLASS = 'rosetta.storage.SessionRosettaStorage'
  65. ROSETTA_ENABLE_TRANSLATION_SUGGESTIONS = True
  66. ROSETTA_REQUIRES_AUTH = False
  67. SITE_ID = 1
  68. # If you set this to False, Django will make some optimizations so as not
  69. # to load the internationalization machinery.
  70. USE_I18N = True
  71. # If you set this to False, Django will not format dates, numbers and
  72. # calendars according to the current locale
  73. USE_L10N = True
  74. # Absolute path to the directory that holds media.
  75. # Example: "/home/media/media.lawrence.com/"
  76. MEDIA_ROOT = location("public/media")
  77. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  78. # trailing slash if there is a path component (optional in other cases).
  79. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  80. MEDIA_URL = '/media/'
  81. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  82. # trailing slash.
  83. # Examples: "http://foo.com/media/", "/media/".
  84. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  85. STATIC_URL = '/static/'
  86. STATIC_ROOT = location('public/static')
  87. STATICFILES_DIRS = (
  88. location('static/'),
  89. )
  90. STATICFILES_FINDERS = (
  91. 'django.contrib.staticfiles.finders.FileSystemFinder',
  92. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  93. 'compressor.finders.CompressorFinder',
  94. )
  95. # Make this unique, and don't share it with anybody.
  96. SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  97. # List of callables that know how to import templates from various sources.
  98. TEMPLATE_LOADERS = (
  99. 'django.template.loaders.filesystem.Loader',
  100. 'django.template.loaders.app_directories.Loader',
  101. # needed by django-treebeard for admin (and potentially other libs)
  102. 'django.template.loaders.eggs.Loader',
  103. )
  104. TEMPLATE_CONTEXT_PROCESSORS = (
  105. "django.contrib.auth.context_processors.auth",
  106. "django.core.context_processors.request",
  107. "django.core.context_processors.debug",
  108. "django.core.context_processors.i18n",
  109. "django.core.context_processors.media",
  110. "django.core.context_processors.static",
  111. "django.contrib.messages.context_processors.messages",
  112. # Oscar specific
  113. 'oscar.apps.search.context_processors.search_form',
  114. 'oscar.apps.promotions.context_processors.promotions',
  115. 'oscar.apps.checkout.context_processors.checkout',
  116. 'oscar.core.context_processors.metadata',
  117. 'oscar.apps.customer.notifications.context_processors.notifications',
  118. )
  119. MIDDLEWARE_CLASSES = (
  120. 'django.contrib.sessions.middleware.SessionMiddleware',
  121. 'django.middleware.csrf.CsrfViewMiddleware',
  122. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  123. 'django.contrib.messages.middleware.MessageMiddleware',
  124. 'django.middleware.transaction.TransactionMiddleware',
  125. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  126. # Allow languages to be selected
  127. 'django.middleware.locale.LocaleMiddleware',
  128. 'django.middleware.common.CommonMiddleware',
  129. # Ensure a valid basket is added to the request instance for every request
  130. 'oscar.apps.basket.middleware.BasketMiddleware',
  131. # Enable the ProfileMiddleware, then add ?cprofile to any
  132. # URL path to print out profile details
  133. #'oscar.profiling.middleware.ProfileMiddleware',
  134. )
  135. ROOT_URLCONF = 'urls'
  136. # Add another path to Oscar's templates. This allows templates to be
  137. # customised easily.
  138. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  139. TEMPLATE_DIRS = (
  140. location('templates'),
  141. OSCAR_MAIN_TEMPLATE_DIR,
  142. )
  143. # A sample logging configuration. The only tangible logging
  144. # performed by this configuration is to send an email to
  145. # the site admins on every HTTP 500 error.
  146. # See http://docs.djangoproject.com/en/dev/topics/logging for
  147. # more details on how to customize your logging configuration.
  148. LOGGING = {
  149. 'version': 1,
  150. 'disable_existing_loggers': True,
  151. 'formatters': {
  152. 'verbose': {
  153. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  154. },
  155. 'simple': {
  156. 'format': '[%(asctime)s] %(message)s'
  157. },
  158. },
  159. 'filters': {
  160. 'require_debug_false': {
  161. '()': 'django.utils.log.RequireDebugFalse'
  162. }
  163. },
  164. 'handlers': {
  165. 'null': {
  166. 'level': 'DEBUG',
  167. 'class': 'django.utils.log.NullHandler',
  168. },
  169. 'console': {
  170. 'level': 'DEBUG',
  171. 'class': 'logging.StreamHandler',
  172. 'formatter': 'verbose'
  173. },
  174. 'checkout_file': {
  175. 'level': 'INFO',
  176. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  177. 'filename': 'checkout.log',
  178. 'formatter': 'verbose'
  179. },
  180. 'gateway_file': {
  181. 'level': 'INFO',
  182. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  183. 'filename': 'gateway.log',
  184. 'formatter': 'simple'
  185. },
  186. 'error_file': {
  187. 'level': 'INFO',
  188. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  189. 'filename': 'errors.log',
  190. 'formatter': 'verbose'
  191. },
  192. 'sorl_file': {
  193. 'level': 'INFO',
  194. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  195. 'filename': 'sorl.log',
  196. 'formatter': 'verbose'
  197. },
  198. 'mail_admins': {
  199. 'level': 'ERROR',
  200. 'class': 'django.utils.log.AdminEmailHandler',
  201. 'filters': ['require_debug_false'],
  202. },
  203. },
  204. 'loggers': {
  205. # Django loggers
  206. 'django': {
  207. 'handlers': ['null'],
  208. 'propagate': True,
  209. 'level': 'INFO',
  210. },
  211. 'django.request': {
  212. 'handlers': ['mail_admins', 'error_file'],
  213. 'level': 'ERROR',
  214. 'propagate': False,
  215. },
  216. 'django.db.backends': {
  217. 'handlers': ['null'],
  218. 'propagate': False,
  219. 'level': 'DEBUG',
  220. },
  221. # Oscar core loggers
  222. 'oscar.checkout': {
  223. 'handlers': ['console', 'checkout_file'],
  224. 'propagate': False,
  225. 'level': 'INFO',
  226. },
  227. 'oscar.catalogue.import': {
  228. 'handlers': ['console'],
  229. 'propagate': False,
  230. 'level': 'INFO',
  231. },
  232. 'oscar.alerts': {
  233. 'handlers': ['null'],
  234. 'propagate': False,
  235. 'level': 'INFO',
  236. },
  237. # Sandbox logging
  238. 'gateway': {
  239. 'handlers': ['gateway_file'],
  240. 'propagate': True,
  241. 'level': 'INFO',
  242. },
  243. # Third party
  244. 'south': {
  245. 'handlers': ['null'],
  246. 'propagate': True,
  247. 'level': 'INFO',
  248. },
  249. 'sorl.thumbnail': {
  250. 'handlers': ['sorl_file'],
  251. 'propagate': True,
  252. 'level': 'INFO',
  253. },
  254. # Suppress output of this debug toolbar panel
  255. 'template_timings_panel': {
  256. 'handlers': ['null'],
  257. 'level': 'DEBUG',
  258. 'propagate': False,
  259. }
  260. }
  261. }
  262. INSTALLED_APPS = [
  263. 'django.contrib.auth',
  264. 'django.contrib.contenttypes',
  265. 'django.contrib.sessions',
  266. 'django.contrib.sites',
  267. 'django.contrib.messages',
  268. 'django.contrib.admin',
  269. 'django.contrib.flatpages',
  270. 'django.contrib.staticfiles',
  271. 'django_extensions',
  272. # Debug toolbar + extensions
  273. 'debug_toolbar',
  274. 'template_timings_panel',
  275. 'south',
  276. 'rosetta', # For i18n testing
  277. 'compressor',
  278. 'apps.gateway', # For allowing dashboard access
  279. ]
  280. from oscar import get_core_apps
  281. INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
  282. # Add Oscar's custom auth backend so users can sign in using their email
  283. # address.
  284. AUTHENTICATION_BACKENDS = (
  285. 'oscar.apps.customer.auth_backends.Emailbackend',
  286. 'django.contrib.auth.backends.ModelBackend',
  287. )
  288. LOGIN_REDIRECT_URL = '/'
  289. APPEND_SLASH = True
  290. # Haystack settings
  291. HAYSTACK_CONNECTIONS = {
  292. 'default': {
  293. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  294. 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
  295. },
  296. }
  297. # =============
  298. # Debug Toolbar
  299. # =============
  300. DEBUG_TOOLBAR_PANELS = [
  301. 'debug_toolbar.panels.versions.VersionsPanel',
  302. 'debug_toolbar.panels.timer.TimerPanel',
  303. 'debug_toolbar.panels.settings.SettingsPanel',
  304. 'debug_toolbar.panels.headers.HeadersPanel',
  305. 'debug_toolbar.panels.request.RequestPanel',
  306. 'debug_toolbar.panels.sql.SQLPanel',
  307. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  308. 'debug_toolbar.panels.templates.TemplatesPanel',
  309. 'template_timings_panel.panels.TemplateTimings.TemplateTimings',
  310. 'debug_toolbar.panels.cache.CachePanel',
  311. 'debug_toolbar.panels.signals.SignalsPanel',
  312. 'debug_toolbar.panels.logging.LoggingPanel',
  313. 'debug_toolbar.panels.redirects.RedirectsPanel',
  314. ]
  315. # ==============
  316. # Oscar settings
  317. # ==============
  318. from oscar.defaults import *
  319. # Meta
  320. # ====
  321. OSCAR_SHOP_TAGLINE = 'Sandbox'
  322. # Enter Google Analytics ID for the tracking to be included in the templates
  323. GOOGLE_ANALYTICS_ID = 'UA-45363517-3'
  324. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  325. OSCAR_ALLOW_ANON_CHECKOUT = True
  326. # This is added to each template context by the core context processor. It is
  327. # useful for test/stage/qa sites where you want to show the version of the site
  328. # in the page title.
  329. DISPLAY_VERSION = False
  330. # Order processing
  331. # ================
  332. # Some sample order/line status settings
  333. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  334. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  335. OSCAR_ORDER_STATUS_PIPELINE = {
  336. 'Pending': ('Being processed', 'Cancelled',),
  337. 'Being processed': ('Processed', 'Cancelled',),
  338. 'Cancelled': (),
  339. 'Processed': (),
  340. }
  341. # LESS/CSS/statics
  342. # ================
  343. # We default to using CSS files, rather than the LESS files that generate them.
  344. # If you want to develop Oscar's CSS, then set USE_LESS=True and
  345. # COMPRESS_ENABLED=False in your settings_local module and ensure you have
  346. # 'lessc' installed. You can do this by running:
  347. #
  348. # pip install -r requirements_less.txt
  349. #
  350. # which will install node.js and less in your virtualenv.
  351. USE_LESS = False
  352. COMPRESS_ENABLED = True
  353. COMPRESS_PRECOMPILERS = (
  354. ('text/less', 'lessc {infile} {outfile}'),
  355. )
  356. COMPRESS_OFFLINE_CONTEXT = {
  357. 'STATIC_URL': 'STATIC_URL',
  358. 'use_less': USE_LESS,
  359. }
  360. # We do this to work around an issue in compressor where the LESS files are
  361. # compiled but compression isn't enabled. When this happens, the relative URL
  362. # is wrong between the generated CSS file and other assets:
  363. # https://github.com/jezdez/django_compressor/issues/226
  364. COMPRESS_OUTPUT_DIR = 'oscar'
  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. # Use a custom KV store to handle integrity error
  376. THUMBNAIL_KVSTORE = 'oscar.sorl_kvstore.ConcurrentKVStore'
  377. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  378. # serialize Models. We should resolve this by extending the
  379. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  380. # in tests/config.py
  381. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  382. # Try and import local settings which can be used to override any of the above.
  383. try:
  384. from settings_local import *
  385. except ImportError:
  386. pass