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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. THUMBNAIL_DEBUG = True
  12. ADMINS = (
  13. ('David Winterbottom', 'david.winterbottom@tangentlabs.co.uk'),
  14. )
  15. EMAIL_SUBJECT_PREFIX = '[Oscar sandbox] '
  16. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  17. MANAGERS = ADMINS
  18. # Use a Sqlite database by default
  19. DATABASES = {
  20. 'default': {
  21. 'ENGINE': 'django.db.backends.sqlite3',
  22. 'NAME': os.path.join(os.path.dirname(__file__), 'db.sqlite'),
  23. 'USER': '',
  24. 'PASSWORD': '',
  25. 'HOST': '',
  26. 'PORT': '',
  27. }
  28. }
  29. CACHES = {
  30. 'default': {
  31. 'BACKEND':
  32. 'django.core.cache.backends.memcached.MemcachedCache',
  33. 'LOCATION': '127.0.0.1:11211',
  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. # 'django.template.loaders.eggs.Loader',
  99. )
  100. TEMPLATE_CONTEXT_PROCESSORS = (
  101. "django.contrib.auth.context_processors.auth",
  102. "django.core.context_processors.request",
  103. "django.core.context_processors.debug",
  104. "django.core.context_processors.i18n",
  105. "django.core.context_processors.media",
  106. "django.core.context_processors.static",
  107. "django.contrib.messages.context_processors.messages",
  108. # Oscar specific
  109. 'oscar.apps.search.context_processors.search_form',
  110. 'oscar.apps.promotions.context_processors.promotions',
  111. 'oscar.apps.checkout.context_processors.checkout',
  112. 'oscar.core.context_processors.metadata',
  113. 'oscar.apps.customer.notifications.context_processors.notifications',
  114. )
  115. MIDDLEWARE_CLASSES = (
  116. 'django.contrib.sessions.middleware.SessionMiddleware',
  117. 'django.middleware.csrf.CsrfViewMiddleware',
  118. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  119. 'django.contrib.messages.middleware.MessageMiddleware',
  120. 'django.middleware.transaction.TransactionMiddleware',
  121. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  122. #'debug_toolbar.middleware.DebugToolbarMiddleware',
  123. # Allow languages to be selected
  124. 'django.middleware.locale.LocaleMiddleware',
  125. 'django.middleware.common.CommonMiddleware',
  126. # Ensure a valid basket is added to the request instance for every request
  127. 'oscar.apps.basket.middleware.BasketMiddleware',
  128. # Enable the ProfileMiddleware, then add ?cprofile to any
  129. # URL path to print out profile details
  130. #'oscar.profiling.middleware.ProfileMiddleware',
  131. )
  132. INTERNAL_IPS = ('127.0.0.1',)
  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. 'handlers': {
  158. 'null': {
  159. 'level': 'DEBUG',
  160. 'class': 'django.utils.log.NullHandler',
  161. },
  162. 'console': {
  163. 'level': 'DEBUG',
  164. 'class': 'logging.StreamHandler',
  165. 'formatter': 'verbose'
  166. },
  167. 'checkout_file': {
  168. 'level': 'INFO',
  169. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  170. 'filename': 'checkout.log',
  171. 'formatter': 'verbose'
  172. },
  173. 'gateway_file': {
  174. 'level': 'INFO',
  175. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  176. 'filename': 'gateway.log',
  177. 'formatter': 'simple'
  178. },
  179. 'error_file': {
  180. 'level': 'INFO',
  181. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  182. 'filename': 'errors.log',
  183. 'formatter': 'verbose'
  184. },
  185. 'sorl_file': {
  186. 'level': 'INFO',
  187. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  188. 'filename': 'sorl.log',
  189. 'formatter': 'verbose'
  190. },
  191. 'mail_admins': {
  192. 'level': 'ERROR',
  193. 'class': 'django.utils.log.AdminEmailHandler',
  194. },
  195. },
  196. 'loggers': {
  197. 'django': {
  198. 'handlers': ['null'],
  199. 'propagate': True,
  200. 'level': 'INFO',
  201. },
  202. 'django.request': {
  203. 'handlers': ['mail_admins', 'error_file'],
  204. 'level': 'ERROR',
  205. 'propagate': False,
  206. },
  207. 'oscar.checkout': {
  208. 'handlers': ['console', 'checkout_file'],
  209. 'propagate': True,
  210. 'level': 'INFO',
  211. },
  212. 'gateway': {
  213. 'handlers': ['gateway_file'],
  214. 'propagate': True,
  215. 'level': 'INFO',
  216. },
  217. 'sorl.thumbnail': {
  218. 'handlers': ['sorl_file'],
  219. 'propagate': True,
  220. 'level': 'INFO',
  221. },
  222. 'django.db.backends': {
  223. 'handlers': ['null'],
  224. 'propagate': False,
  225. 'level': 'DEBUG',
  226. },
  227. }
  228. }
  229. INSTALLED_APPS = [
  230. 'django.contrib.auth',
  231. 'django.contrib.contenttypes',
  232. 'django.contrib.sessions',
  233. 'django.contrib.sites',
  234. 'django.contrib.messages',
  235. 'django.contrib.admin',
  236. 'django.contrib.flatpages',
  237. 'django.contrib.staticfiles',
  238. 'django_extensions',
  239. 'debug_toolbar',
  240. 'south',
  241. 'rosetta', # For i18n testing
  242. 'compressor',
  243. 'apps.user', # For profile testing
  244. 'apps.gateway', # For allowing dashboard access
  245. ]
  246. from oscar import get_core_apps
  247. INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
  248. # Add Oscar's custom auth backend so users can sign in using their email
  249. # address.
  250. AUTHENTICATION_BACKENDS = (
  251. 'oscar.apps.customer.auth_backends.Emailbackend',
  252. 'django.contrib.auth.backends.ModelBackend',
  253. )
  254. LOGIN_REDIRECT_URL = '/accounts/'
  255. APPEND_SLASH = True
  256. # Haystack settings
  257. HAYSTACK_CONNECTIONS = {
  258. 'default': {
  259. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  260. 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
  261. },
  262. }
  263. # Allow internal IPs to see the debug toolbar. This is just for Tangent's QA
  264. # department to be able to create better issues when something goes wrong.
  265. def is_internal(request):
  266. ip_addr = request.META['REMOTE_ADDR']
  267. return ip_addr in INTERNAL_IPS or ip_addr.startswith('192.168')
  268. DEBUG_TOOLBAR_CONFIG = {
  269. 'INTERCEPT_REDIRECTS': False,
  270. 'SHOW_TOOLBAR_CALLBACK': is_internal
  271. }
  272. AUTH_PROFILE_MODULE = 'user.Profile'
  273. # ==============
  274. # Oscar settings
  275. # ==============
  276. from oscar.defaults import *
  277. # Meta
  278. # ====
  279. OSCAR_SHOP_NAME = 'Oscar Sandbox'
  280. OSCAR_SHOP_TAGLINE = 'e-Commerce for Django'
  281. # Enter Google Analytics ID for the tracking to be included in the templates
  282. #GOOGLE_ANALYTICS_ID = 'UA-XXXXX-Y'
  283. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  284. OSCAR_ALLOW_ANON_CHECKOUT = True
  285. # This is added to each template context by the core context processor. It is
  286. # useful for test/stage/qa sites where you want to show the version of the site
  287. # in the page title.
  288. DISPLAY_VERSION = False
  289. # Order processing
  290. # ================
  291. # Some sample order/line status settings
  292. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  293. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  294. OSCAR_ORDER_STATUS_PIPELINE = {
  295. 'Pending': ('Being processed', 'Cancelled',),
  296. 'Being processed': ('Processed', 'Cancelled',),
  297. 'Cancelled': (),
  298. }
  299. # LESS/CSS/statics
  300. # ================
  301. # We default to using CSS files, rather than the LESS files that generate them.
  302. # If you want to develop Oscar's CSS, then set USE_LESS=True and
  303. # COMPRESS_ENABLED=False in your settings_local module and ensure you have
  304. # 'lessc' installed. You can do this by running:
  305. #
  306. # pip install -r requirements_less.txt
  307. #
  308. # which will install node.js and less in your virtualenv.
  309. USE_LESS = False
  310. COMPRESS_ENABLED = True
  311. COMPRESS_PRECOMPILERS = (
  312. ('text/less', 'lessc {infile} {outfile}'),
  313. )
  314. COMPRESS_OFFLINE_CONTEXT = {
  315. 'STATIC_URL': 'STATIC_URL',
  316. 'use_less': USE_LESS,
  317. }
  318. # Logging
  319. # =======
  320. LOG_ROOT = location('logs')
  321. # Ensure log root exists
  322. if not os.path.exists(LOG_ROOT):
  323. os.mkdir(LOG_ROOT)
  324. # Try and import local settings which can be used to override any of the above.
  325. try:
  326. from settings_local import *
  327. except ImportError:
  328. pass