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

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