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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. """
  2. Settings for Oscar's demo site.
  3. Notes:
  4. * The demo site uses the stores extension which requires a spatial database.
  5. Only the postgis and spatialite backends are tested, but all backends
  6. supported by GeoDjango should work.
  7. """
  8. import os
  9. # Django settings for oscar project.
  10. location = lambda x: os.path.join(
  11. os.path.dirname(os.path.realpath(__file__)), x)
  12. DEBUG = True
  13. TEMPLATE_DEBUG = True
  14. SQL_DEBUG = True
  15. EMAIL_SUBJECT_PREFIX = '[Oscar demo] '
  16. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  17. ALLOWED_HOSTS = ['demo.oscarcommerce.com',
  18. 'demo.oscar.tangentlabs.co.uk']
  19. # Use settings_local to override this default
  20. DATABASES = {
  21. 'default': {
  22. 'ENGINE': 'django.contrib.gis.db.backends.postgis',
  23. 'NAME': 'oscar_demo',
  24. 'USER': 'postgres',
  25. 'ATOMIC_REQUESTS': True
  26. },
  27. }
  28. SITE_ID = 1
  29. CACHES = {
  30. 'default': {
  31. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  32. }
  33. }
  34. # Prevent Django 1.7+ from showing a warning regarding a changed default test
  35. # runner. The Oscar test suite is run with nose, so it does not matter.
  36. SILENCED_SYSTEM_CHECKS = ['1_6.W001', ]
  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. LANGUAGES = (
  49. ('en-gb', 'English'),
  50. )
  51. # If you set this to False, Django will make some optimizations so as not
  52. # to load the internationalization machinery.
  53. USE_I18N = True
  54. # Absolute path to the directory that holds media.
  55. # Example: "/home/media/media.lawrence.com/"
  56. MEDIA_ROOT = location("public/media")
  57. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  58. # trailing slash if there is a path component (optional in other cases).
  59. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  60. MEDIA_URL = '/media/'
  61. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  62. # trailing slash.
  63. # Examples: "http://foo.com/media/", "/media/".
  64. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  65. STATIC_URL = '/static/'
  66. STATICFILES_DIRS = (
  67. location('static'),
  68. )
  69. STATIC_ROOT = location('public/static')
  70. STATICFILES_FINDERS = (
  71. 'django.contrib.staticfiles.finders.FileSystemFinder',
  72. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  73. 'compressor.finders.CompressorFinder',
  74. )
  75. # Make this unique, and don't share it with anybody.
  76. SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  77. # List of callables that know how to import templates from various sources.
  78. TEMPLATE_LOADERS = (
  79. 'django.template.loaders.filesystem.Loader',
  80. 'django.template.loaders.app_directories.Loader',
  81. # needed by django-treebeard for admin (and potentially other libs)
  82. 'django.template.loaders.eggs.Loader',
  83. )
  84. TEMPLATE_CONTEXT_PROCESSORS = (
  85. "django.contrib.auth.context_processors.auth",
  86. "django.core.context_processors.request",
  87. "django.core.context_processors.debug",
  88. "django.core.context_processors.i18n",
  89. "django.core.context_processors.media",
  90. "django.core.context_processors.static",
  91. "django.contrib.messages.context_processors.messages",
  92. # Oscar specific
  93. 'oscar.apps.search.context_processors.search_form',
  94. 'oscar.apps.promotions.context_processors.promotions',
  95. 'oscar.apps.checkout.context_processors.checkout',
  96. 'oscar.core.context_processors.metadata',
  97. 'oscar.apps.customer.notifications.context_processors.notifications',
  98. )
  99. MIDDLEWARE_CLASSES = (
  100. 'django.middleware.common.CommonMiddleware',
  101. 'django.contrib.sessions.middleware.SessionMiddleware',
  102. 'django.middleware.csrf.CsrfViewMiddleware',
  103. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  104. 'django.contrib.messages.middleware.MessageMiddleware',
  105. 'django.middleware.transaction.TransactionMiddleware',
  106. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  107. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  108. 'oscar.apps.basket.middleware.BasketMiddleware',
  109. )
  110. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  111. INTERNAL_IPS = ('127.0.0.1',)
  112. ROOT_URLCONF = 'urls'
  113. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  114. TEMPLATE_DIRS = (
  115. location('templates'),
  116. OSCAR_MAIN_TEMPLATE_DIR,
  117. )
  118. # A sample logging configuration. The only tangible logging
  119. # performed by this configuration is to send an email to
  120. # the site admins on every HTTP 500 error.
  121. # See http://docs.djangoproject.com/en/dev/topics/logging for
  122. # more details on how to customize your logging configuration.
  123. LOGGING = {
  124. 'version': 1,
  125. 'disable_existing_loggers': False,
  126. 'formatters': {
  127. 'verbose': {
  128. 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
  129. },
  130. 'simple': {
  131. 'format': '%(levelname)s %(message)s'
  132. },
  133. },
  134. 'filters': {
  135. 'require_debug_false': {
  136. '()': 'django.utils.log.RequireDebugFalse'
  137. }
  138. },
  139. 'handlers': {
  140. 'null': {
  141. 'level': 'DEBUG',
  142. 'class': 'django.utils.log.NullHandler',
  143. },
  144. 'console': {
  145. 'level': 'DEBUG',
  146. 'class': 'logging.StreamHandler',
  147. 'formatter': 'verbose'
  148. },
  149. 'checkout_file': {
  150. 'level': 'INFO',
  151. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  152. 'filename': 'checkout.log',
  153. 'formatter': 'verbose'
  154. },
  155. 'error_file': {
  156. 'level': 'INFO',
  157. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  158. 'filename': 'errors.log',
  159. 'formatter': 'verbose'
  160. },
  161. 'mail_admins': {
  162. 'level': 'ERROR',
  163. 'class': 'django.utils.log.AdminEmailHandler',
  164. 'filters': ['require_debug_false'],
  165. },
  166. },
  167. 'loggers': {
  168. 'django': {
  169. 'handlers': ['null'],
  170. 'propagate': True,
  171. 'level': 'INFO',
  172. },
  173. 'django.request': {
  174. 'handlers': ['mail_admins', 'error_file'],
  175. 'level': 'ERROR',
  176. 'propagate': False,
  177. },
  178. 'oscar.checkout': {
  179. 'handlers': ['console', 'checkout_file'],
  180. 'propagate': True,
  181. 'level': 'INFO',
  182. },
  183. 'datacash': {
  184. 'handlers': ['console'],
  185. 'propagate': True,
  186. 'level': 'INFO',
  187. },
  188. 'django.db.backends': {
  189. 'handlers': ['null'],
  190. 'propagate': False,
  191. 'level': 'DEBUG',
  192. },
  193. }
  194. }
  195. INSTALLED_APPS = [
  196. 'django.contrib.auth',
  197. 'django.contrib.contenttypes',
  198. 'django.contrib.sessions',
  199. 'django.contrib.sites',
  200. 'django.contrib.messages',
  201. 'django.contrib.admin',
  202. 'django.contrib.flatpages',
  203. 'django.contrib.staticfiles',
  204. 'django.contrib.gis',
  205. # Oscar dependencies
  206. 'compressor',
  207. # Oscar extensions
  208. 'stores',
  209. 'paypal',
  210. 'datacash',
  211. # External apps
  212. 'django_extensions',
  213. 'debug_toolbar',
  214. # For profile testing
  215. 'apps.user',
  216. # Sentry (for live demo site)
  217. 'raven.contrib.django.raven_compat'
  218. ]
  219. # South is only supported in Django < 1.7
  220. import django
  221. if django.VERSION < (1, 7):
  222. INSTALLED_APPS.append('south')
  223. # Include core apps with a few overrides:
  224. # - a shipping override app to provide some shipping methods
  225. # - an order app to provide order processing logic
  226. from oscar import get_core_apps
  227. INSTALLED_APPS = INSTALLED_APPS + get_core_apps(
  228. ['apps.shipping', 'apps.order'])
  229. AUTHENTICATION_BACKENDS = (
  230. 'oscar.apps.customer.auth_backends.EmailBackend',
  231. 'django.contrib.auth.backends.ModelBackend',
  232. )
  233. LOGIN_REDIRECT_URL = '/'
  234. APPEND_SLASH = True
  235. # Haystack settings - we use a local Solr instance running on the default port
  236. HAYSTACK_CONNECTIONS = {
  237. 'default': {
  238. 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  239. 'URL': 'http://127.0.0.1:8983/solr',
  240. },
  241. }
  242. # We still use this deprecated Django setting since Oscar needs a way of
  243. # knowing where the profile class is (if one is used).
  244. AUTH_PROFILE_MODULE = 'user.Profile'
  245. # Oscar settings
  246. from oscar.defaults import *
  247. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  248. OSCAR_ALLOW_ANON_CHECKOUT = True
  249. OSCAR_SHOP_NAME = 'Oscar'
  250. OSCAR_SHOP_TAGLINE = 'Demo'
  251. COMPRESS_ENABLED = False
  252. COMPRESS_PRECOMPILERS = (
  253. ('text/less', 'lessc {infile} {outfile}'),
  254. )
  255. THUMBNAIL_KEY_PREFIX = 'oscar-demo'
  256. LOG_ROOT = location('logs')
  257. # Ensure log root exists
  258. if not os.path.exists(LOG_ROOT):
  259. os.mkdir(LOG_ROOT)
  260. DISPLAY_VERSION = False
  261. USE_TZ = True
  262. # Must be within MEDIA_ROOT for sorl to work
  263. OSCAR_MISSING_IMAGE_URL = 'image_not_found.jpg'
  264. GOOGLE_ANALYTICS_ID = 'UA-45363517-4'
  265. # Add stores node to navigation
  266. new_nav = OSCAR_DASHBOARD_NAVIGATION
  267. new_nav.append(
  268. {
  269. 'label': 'Stores',
  270. 'icon': 'icon-shopping-cart',
  271. 'children': [
  272. {
  273. 'label': 'Stores',
  274. 'url_name': 'stores-dashboard:store-list',
  275. },
  276. {
  277. 'label': 'Store groups',
  278. 'url_name': 'stores-dashboard:store-group-list',
  279. },
  280. ]
  281. })
  282. new_nav.append(
  283. {
  284. 'label': 'Datacash',
  285. 'icon': 'icon-globe',
  286. 'children': [
  287. {
  288. 'label': 'Transactions',
  289. 'url_name': 'datacash-transaction-list',
  290. },
  291. ]
  292. })
  293. OSCAR_DASHBOARD_NAVIGATION = new_nav
  294. GEOIP_PATH = os.path.join(os.path.dirname(__file__), 'geoip')
  295. # Note, client and password are omitted here. They are assigned in
  296. # settings_local but kept out of source control.
  297. DATACASH_HOST = 'testserver.datacash.com'
  298. DATACASH_CLIENT = ''
  299. DATACASH_PASSWORD = ''
  300. DATACASH_USE_CV2AVS = True
  301. DATACASH_CURRENCY = 'GBP'
  302. # Some mildly sensitive settings are kept out this file, such as the secret
  303. # key, paypal credentials and datacash credentials. If you want to test the
  304. # full checkout process of the demo site locally then then you'll need to
  305. # assign your own payment gateway details in settings_local.py. This may
  306. # involve signing up for a Datacash or PayPal account.
  307. try:
  308. from settings_local import *
  309. except ImportError:
  310. pass