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

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