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 12KB

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