Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

settings.py 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. location('static/'),
  88. )
  89. STATICFILES_FINDERS = (
  90. 'django.contrib.staticfiles.finders.FileSystemFinder',
  91. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  92. 'compressor.finders.CompressorFinder',
  93. )
  94. # Make this unique, and don't share it with anybody.
  95. SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  96. # List of callables that know how to import templates from various sources.
  97. TEMPLATE_LOADERS = (
  98. 'django.template.loaders.filesystem.Loader',
  99. 'django.template.loaders.app_directories.Loader',
  100. # needed by django-treebeard for admin (and potentially other libs)
  101. 'django.template.loaders.eggs.Loader',
  102. )
  103. TEMPLATE_CONTEXT_PROCESSORS = (
  104. "django.contrib.auth.context_processors.auth",
  105. "django.core.context_processors.request",
  106. "django.core.context_processors.debug",
  107. "django.core.context_processors.i18n",
  108. "django.core.context_processors.media",
  109. "django.core.context_processors.static",
  110. "django.contrib.messages.context_processors.messages",
  111. # Oscar specific
  112. 'oscar.apps.search.context_processors.search_form',
  113. 'oscar.apps.promotions.context_processors.promotions',
  114. 'oscar.apps.checkout.context_processors.checkout',
  115. 'oscar.core.context_processors.metadata',
  116. 'oscar.apps.customer.notifications.context_processors.notifications',
  117. )
  118. MIDDLEWARE_CLASSES = (
  119. 'django.contrib.sessions.middleware.SessionMiddleware',
  120. 'django.middleware.csrf.CsrfViewMiddleware',
  121. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  122. 'django.contrib.messages.middleware.MessageMiddleware',
  123. 'django.middleware.transaction.TransactionMiddleware',
  124. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  125. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  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': False,
  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': {
  206. 'handlers': ['null'],
  207. 'propagate': True,
  208. 'level': 'INFO',
  209. },
  210. 'django.request': {
  211. 'handlers': ['mail_admins', 'error_file'],
  212. 'level': 'ERROR',
  213. 'propagate': False,
  214. },
  215. 'oscar.checkout': {
  216. 'handlers': ['console', 'checkout_file'],
  217. 'propagate': False,
  218. 'level': 'INFO',
  219. },
  220. 'oscar.catalogue.import': {
  221. 'handlers': ['console'],
  222. 'propagate': False,
  223. 'level': 'INFO',
  224. },
  225. 'gateway': {
  226. 'handlers': ['gateway_file'],
  227. 'propagate': True,
  228. 'level': 'INFO',
  229. },
  230. 'sorl.thumbnail': {
  231. 'handlers': ['sorl_file'],
  232. 'propagate': True,
  233. 'level': 'INFO',
  234. },
  235. 'django.db.backends': {
  236. 'handlers': ['null'],
  237. 'propagate': False,
  238. 'level': 'DEBUG',
  239. },
  240. # suppress output of this debug toolbar panel
  241. 'template_timings_panel': {
  242. 'handlers': ['null'],
  243. 'level': 'DEBUG',
  244. 'propagate': False,
  245. }
  246. }
  247. }
  248. INSTALLED_APPS = [
  249. 'django.contrib.auth',
  250. 'django.contrib.contenttypes',
  251. 'django.contrib.sessions',
  252. 'django.contrib.sites',
  253. 'django.contrib.messages',
  254. 'django.contrib.admin',
  255. 'django.contrib.flatpages',
  256. 'django.contrib.staticfiles',
  257. 'django_extensions',
  258. # Debug toolbar + extensions
  259. 'debug_toolbar',
  260. 'cache_panel',
  261. #'template_timings_panel',
  262. 'south',
  263. 'rosetta', # For i18n testing
  264. 'compressor',
  265. 'apps.gateway', # For allowing dashboard access
  266. ]
  267. from oscar import get_core_apps
  268. INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
  269. # Add Oscar's custom auth backend so users can sign in using their email
  270. # address.
  271. AUTHENTICATION_BACKENDS = (
  272. 'oscar.apps.customer.auth_backends.Emailbackend',
  273. 'django.contrib.auth.backends.ModelBackend',
  274. )
  275. LOGIN_REDIRECT_URL = '/'
  276. APPEND_SLASH = True
  277. # Haystack settings
  278. HAYSTACK_CONNECTIONS = {
  279. 'default': {
  280. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  281. 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
  282. },
  283. }
  284. # =============
  285. # Debug Toolbar
  286. # =============
  287. INTERNAL_IPS = ('127.0.0.1',)
  288. # Allow internal IPs to see the debug toolbar. This is just for Tangent's QA
  289. # department to be able to create better issues when something goes wrong.
  290. def is_internal(request):
  291. ip_addr = request.META['REMOTE_ADDR']
  292. return ip_addr in INTERNAL_IPS or ip_addr.startswith('192.168')
  293. DEBUG_TOOLBAR_CONFIG = {
  294. 'INTERCEPT_REDIRECTS': False,
  295. 'SHOW_TOOLBAR_CALLBACK': is_internal
  296. }
  297. DEBUG_TOOLBAR_PANELS = (
  298. 'debug_toolbar.panels.headers.HeaderDebugPanel',
  299. 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
  300. 'debug_toolbar.panels.template.TemplateDebugPanel',
  301. 'debug_toolbar.panels.timer.TimerDebugPanel',
  302. 'debug_toolbar.panels.sql.SQLDebugPanel',
  303. #'template_timings_panel.panels.TemplateTimings.TemplateTimings',
  304. 'cache_panel.panel.CacheDebugPanel',
  305. 'debug_toolbar.panels.signals.SignalDebugPanel',
  306. 'debug_toolbar.panels.logger.LoggingPanel',
  307. 'debug_toolbar.panels.version.VersionDebugPanel',
  308. 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
  309. )
  310. # ==============
  311. # Oscar settings
  312. # ==============
  313. from oscar.defaults import *
  314. # Meta
  315. # ====
  316. OSCAR_SHOP_TAGLINE = 'Sandbox'
  317. # Enter Google Analytics ID for the tracking to be included in the templates
  318. #GOOGLE_ANALYTICS_ID = 'UA-XXXXX-Y'
  319. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  320. OSCAR_ALLOW_ANON_CHECKOUT = True
  321. # This is added to each template context by the core context processor. It is
  322. # useful for test/stage/qa sites where you want to show the version of the site
  323. # in the page title.
  324. DISPLAY_VERSION = False
  325. # Order processing
  326. # ================
  327. # Some sample order/line status settings
  328. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  329. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  330. OSCAR_ORDER_STATUS_PIPELINE = {
  331. 'Pending': ('Being processed', 'Cancelled',),
  332. 'Being processed': ('Processed', 'Cancelled',),
  333. 'Cancelled': (),
  334. }
  335. # LESS/CSS/statics
  336. # ================
  337. # We default to using CSS files, rather than the LESS files that generate them.
  338. # If you want to develop Oscar's CSS, then set USE_LESS=True and
  339. # COMPRESS_ENABLED=False in your settings_local module and ensure you have
  340. # 'lessc' installed. You can do this by running:
  341. #
  342. # pip install -r requirements_less.txt
  343. #
  344. # which will install node.js and less in your virtualenv.
  345. USE_LESS = False
  346. COMPRESS_ENABLED = True
  347. COMPRESS_PRECOMPILERS = (
  348. ('text/less', 'lessc {infile} {outfile}'),
  349. )
  350. COMPRESS_OFFLINE_CONTEXT = {
  351. 'STATIC_URL': 'STATIC_URL',
  352. 'use_less': USE_LESS,
  353. }
  354. # We do this to work around an issue in compressor where the LESS files are
  355. # compiled but compression isn't enabled. When this happens, the relative URL
  356. # is wrong between the generated CSS file and other assets:
  357. # https://github.com/jezdez/django_compressor/issues/226
  358. COMPRESS_OUTPUT_DIR = 'oscar'
  359. # Logging
  360. # =======
  361. LOG_ROOT = location('logs')
  362. # Ensure log root exists
  363. if not os.path.exists(LOG_ROOT):
  364. os.mkdir(LOG_ROOT)
  365. # Sorl
  366. # ====
  367. THUMBNAIL_DEBUG = True
  368. THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'
  369. # Use a custom KV store to handle integrity error
  370. THUMBNAIL_KVSTORE = 'oscar.sorl_kvstore.ConcurrentKVStore'
  371. # Try and import local settings which can be used to override any of the above.
  372. try:
  373. from settings_local import *
  374. except ImportError:
  375. pass