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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. import os
  2. # Django settings for oscar project.
  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 = True
  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. DATABASES = {
  18. 'default': {
  19. 'ENGINE': 'django.db.backends.sqlite3',
  20. 'NAME': os.path.join(os.path.dirname(__file__), 'db.sqlite'),
  21. 'USER': '',
  22. 'PASSWORD': '',
  23. 'HOST': '',
  24. 'PORT': '',
  25. }
  26. }
  27. CACHES = {
  28. 'default': {
  29. 'BACKEND':
  30. 'django.core.cache.backends.memcached.MemcachedCache',
  31. 'LOCATION': '127.0.0.1:11211',
  32. }
  33. }
  34. # Local time zone for this installation. Choices can be found here:
  35. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  36. # although not all choices may be available on all operating systems.
  37. # On Unix systems, a value of None will cause Django to use the same
  38. # timezone as the operating system.
  39. # If running in a Windows environment this must be set to the same as your
  40. # system time zone.
  41. TIME_ZONE = 'Europe/London'
  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-us'
  45. LANGUAGES = (
  46. ('de', 'German'),
  47. ('fr', 'French'),
  48. )
  49. ROSETTA_STORAGE_CLASS = 'rosetta.storage.SessionRosettaStorage'
  50. ROSETTA_ENABLE_TRANSLATION_SUGGESTIONS = True
  51. SITE_ID = 1
  52. # If you set this to False, Django will make some optimizations so as not
  53. # to load the internationalization machinery.
  54. USE_I18N = True
  55. # If you set this to False, Django will not format dates, numbers and
  56. # calendars according to the current locale
  57. USE_L10N = True
  58. # Absolute path to the directory that holds media.
  59. # Example: "/home/media/media.lawrence.com/"
  60. MEDIA_ROOT = location("assets/media")
  61. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  62. # trailing slash if there is a path component (optional in other cases).
  63. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  64. MEDIA_URL = '/media/'
  65. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  66. # trailing slash.
  67. # Examples: "http://foo.com/media/", "/media/".
  68. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  69. STATIC_URL = '/static/'
  70. STATICFILES_DIRS = ()
  71. STATIC_ROOT = location('public/static')
  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. # 'django.template.loaders.eggs.Loader',
  79. )
  80. TEMPLATE_CONTEXT_PROCESSORS = (
  81. "django.contrib.auth.context_processors.auth",
  82. "django.core.context_processors.request",
  83. "django.core.context_processors.debug",
  84. "django.core.context_processors.i18n",
  85. "django.core.context_processors.media",
  86. "django.core.context_processors.static",
  87. "django.contrib.messages.context_processors.messages",
  88. # Oscar specific
  89. 'oscar.apps.search.context_processors.search_form',
  90. 'oscar.apps.promotions.context_processors.promotions',
  91. 'oscar.apps.checkout.context_processors.checkout',
  92. 'oscar.core.context_processors.metadata',
  93. 'oscar.apps.customer.notifications.context_processors.notifications',
  94. )
  95. MIDDLEWARE_CLASSES = (
  96. 'django.middleware.common.CommonMiddleware',
  97. 'django.contrib.sessions.middleware.SessionMiddleware',
  98. 'django.middleware.csrf.CsrfViewMiddleware',
  99. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  100. 'django.contrib.messages.middleware.MessageMiddleware',
  101. 'django.middleware.transaction.TransactionMiddleware',
  102. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  103. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  104. 'oscar.apps.basket.middleware.BasketMiddleware',
  105. )
  106. INTERNAL_IPS = ('127.0.0.1',)
  107. ROOT_URLCONF = 'urls'
  108. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  109. TEMPLATE_DIRS = (
  110. location('templates'),
  111. OSCAR_MAIN_TEMPLATE_DIR,
  112. )
  113. # A sample logging configuration. The only tangible logging
  114. # performed by this configuration is to send an email to
  115. # the site admins on every HTTP 500 error.
  116. # See http://docs.djangoproject.com/en/dev/topics/logging for
  117. # more details on how to customize your logging configuration.
  118. LOGGING = {
  119. 'version': 1,
  120. 'disable_existing_loggers': False,
  121. 'formatters': {
  122. 'verbose': {
  123. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  124. },
  125. 'simple': {
  126. 'format': '[%(asctime)s] %(message)s'
  127. },
  128. },
  129. 'handlers': {
  130. 'null': {
  131. 'level': 'DEBUG',
  132. 'class': 'django.utils.log.NullHandler',
  133. },
  134. 'console': {
  135. 'level': 'DEBUG',
  136. 'class': 'logging.StreamHandler',
  137. 'formatter': 'verbose'
  138. },
  139. 'checkout_file': {
  140. 'level': 'INFO',
  141. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  142. 'filename': 'checkout.log',
  143. 'formatter': 'verbose'
  144. },
  145. 'gateway_file': {
  146. 'level': 'INFO',
  147. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  148. 'filename': 'gateway.log',
  149. 'formatter': 'simple'
  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. },
  161. },
  162. 'loggers': {
  163. 'django': {
  164. 'handlers': ['null'],
  165. 'propagate': True,
  166. 'level': 'INFO',
  167. },
  168. 'django.request': {
  169. 'handlers': ['mail_admins', 'error_file'],
  170. 'level': 'ERROR',
  171. 'propagate': False,
  172. },
  173. 'oscar.checkout': {
  174. 'handlers': ['console', 'checkout_file'],
  175. 'propagate': True,
  176. 'level': 'INFO',
  177. },
  178. 'gateway': {
  179. 'handlers': ['gateway_file'],
  180. 'propagate': True,
  181. 'level': 'INFO',
  182. },
  183. 'django.db.backends': {
  184. 'handlers': ['null'],
  185. 'propagate': False,
  186. 'level': 'DEBUG',
  187. },
  188. }
  189. }
  190. INSTALLED_APPS = [
  191. 'django.contrib.auth',
  192. 'django.contrib.contenttypes',
  193. 'django.contrib.sessions',
  194. 'django.contrib.sites',
  195. 'django.contrib.messages',
  196. 'django.contrib.admin',
  197. 'django.contrib.flatpages',
  198. 'django.contrib.staticfiles',
  199. 'django_extensions',
  200. 'debug_toolbar',
  201. 'south',
  202. 'rosetta', # For i18n testing
  203. 'apps.user', # For profile testing
  204. 'apps.gateway', # For allowing dashboard access
  205. ]
  206. from oscar import get_core_apps
  207. INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
  208. AUTHENTICATION_BACKENDS = (
  209. 'oscar.apps.customer.auth_backends.Emailbackend',
  210. 'django.contrib.auth.backends.ModelBackend',
  211. )
  212. LOGIN_REDIRECT_URL = '/accounts/'
  213. APPEND_SLASH = True
  214. # Haystack settings
  215. HAYSTACK_CONNECTIONS = {
  216. 'default': {
  217. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  218. 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
  219. },
  220. }
  221. # Allow internal IPs to see the debug toolbar. This is just for Tangent's QA
  222. # department to be able to create better issues when something goes wrong.
  223. def is_internal(request):
  224. ip_addr = request.META['REMOTE_ADDR']
  225. return ip_addr in INTERNAL_IPS or ip_addr.startswith('192.168')
  226. DEBUG_TOOLBAR_CONFIG = {
  227. 'INTERCEPT_REDIRECTS': False,
  228. 'SHOW_TOOLBAR_CALLBACK': is_internal
  229. }
  230. AUTH_PROFILE_MODULE = 'user.Profile'
  231. # Oscar settings
  232. from oscar.defaults import *
  233. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  234. OSCAR_ALLOW_ANON_CHECKOUT = True
  235. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  236. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  237. OSCAR_ORDER_STATUS_PIPELINE = {
  238. 'Pending': ('Being processed', 'Cancelled',),
  239. 'Being processed': ('Processed', 'Cancelled',),
  240. 'Cancelled': (),
  241. }
  242. OSCAR_SHOP_NAME = 'Oscar Sandbox'
  243. OSCAR_SHOP_TAGLINE = 'e-Commerce for Django'
  244. GOOGLE_ANALYTICS_ID = 'UA-XXXXX-Y'
  245. LOG_ROOT = location('logs')
  246. # Ensure log root exists
  247. if not os.path.exists(LOG_ROOT):
  248. os.mkdir(LOG_ROOT)
  249. DISPLAY_VERSION = False
  250. THUMBNAIL_DEBUG = True
  251. # Must be within MEDIA_ROOT for sorl to work
  252. OSCAR_MISSING_IMAGE_URL = 'image_not_found.jpg'
  253. try:
  254. from settings_local import *
  255. except ImportError:
  256. pass