Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

settings.py 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import os
  2. from oscar.defaults import * # noqa
  3. # Path helper
  4. location = lambda x: os.path.join(
  5. os.path.dirname(os.path.realpath(__file__)), x)
  6. ALLOWED_HOSTS = ['test', '.oscarcommerce.com']
  7. DATABASES = {
  8. 'default': {
  9. 'ENGINE': os.environ.get('DATABASE_ENGINE',
  10. 'django.db.backends.postgresql'),
  11. 'NAME': os.environ.get('DATABASE_NAME', 'oscar'),
  12. 'USER': os.environ.get('DATABASE_USER', None),
  13. 'PASSWORD': os.environ.get('DATABASE_USER', None),
  14. }
  15. }
  16. INSTALLED_APPS = [
  17. 'django.contrib.admin',
  18. 'django.contrib.auth',
  19. 'django.contrib.contenttypes',
  20. 'django.contrib.sessions',
  21. 'django.contrib.staticfiles',
  22. 'django.contrib.sites',
  23. 'django.contrib.flatpages',
  24. 'oscar',
  25. 'oscar.apps.analytics',
  26. 'oscar.apps.checkout',
  27. 'oscar.apps.address',
  28. 'oscar.apps.shipping',
  29. 'oscar.apps.catalogue',
  30. 'oscar.apps.catalogue.reviews',
  31. 'oscar.apps.partner',
  32. 'oscar.apps.basket',
  33. 'oscar.apps.payment',
  34. 'oscar.apps.offer',
  35. 'oscar.apps.order',
  36. 'oscar.apps.customer',
  37. 'oscar.apps.search',
  38. 'oscar.apps.voucher',
  39. 'oscar.apps.wishlists',
  40. 'oscar.apps.dashboard',
  41. 'oscar.apps.dashboard.reports',
  42. 'oscar.apps.dashboard.users',
  43. 'oscar.apps.dashboard.orders',
  44. 'oscar.apps.dashboard.catalogue',
  45. 'oscar.apps.dashboard.offers',
  46. 'oscar.apps.dashboard.partners',
  47. 'oscar.apps.dashboard.pages',
  48. 'oscar.apps.dashboard.ranges',
  49. 'oscar.apps.dashboard.reviews',
  50. 'oscar.apps.dashboard.vouchers',
  51. 'oscar.apps.dashboard.communications',
  52. 'oscar.apps.dashboard.shipping',
  53. # 3rd-party apps that oscar depends on
  54. 'widget_tweaks',
  55. 'haystack',
  56. 'treebeard',
  57. 'sorl.thumbnail',
  58. 'easy_thumbnails',
  59. 'django_tables2',
  60. # Contains models we need for testing
  61. 'tests._site.model_tests_app',
  62. 'tests._site.myauth',
  63. ]
  64. # Use a custom partner app to test overriding models. I can't find a way of
  65. # doing this on a per-test basis, so I'm using a global change.
  66. INSTALLED_APPS[INSTALLED_APPS.index('oscar.apps.partner')] = 'tests._site.apps.partner'
  67. INSTALLED_APPS[INSTALLED_APPS.index('oscar.apps.customer')] = 'tests._site.apps.customer'
  68. INSTALLED_APPS[INSTALLED_APPS.index('oscar.apps.catalogue')] = 'tests._site.apps.catalogue'
  69. INSTALLED_APPS[INSTALLED_APPS.index('oscar.apps.dashboard')] = 'tests._site.apps.dashboard'
  70. AUTH_USER_MODEL = 'myauth.User'
  71. TEMPLATES = [
  72. {
  73. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  74. 'DIRS': [
  75. location('_site/templates'),
  76. ],
  77. 'OPTIONS': {
  78. 'loaders': [
  79. ('django.template.loaders.cached.Loader', [
  80. 'django.template.loaders.filesystem.Loader',
  81. 'django.template.loaders.app_directories.Loader',
  82. ]),
  83. ],
  84. 'context_processors': [
  85. 'django.contrib.auth.context_processors.auth',
  86. 'django.template.context_processors.request',
  87. 'django.template.context_processors.debug',
  88. 'django.template.context_processors.i18n',
  89. 'django.template.context_processors.media',
  90. 'django.template.context_processors.static',
  91. 'django.contrib.messages.context_processors.messages',
  92. 'oscar.apps.search.context_processors.search_form',
  93. 'oscar.apps.customer.notifications.context_processors.notifications',
  94. 'oscar.apps.checkout.context_processors.checkout',
  95. 'oscar.core.context_processors.metadata',
  96. ]
  97. }
  98. }
  99. ]
  100. MIDDLEWARE = [
  101. 'django.middleware.common.CommonMiddleware',
  102. 'django.contrib.sessions.middleware.SessionMiddleware',
  103. 'django.middleware.csrf.CsrfViewMiddleware',
  104. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  105. 'django.contrib.messages.middleware.MessageMiddleware',
  106. 'oscar.apps.basket.middleware.BasketMiddleware',
  107. ]
  108. AUTHENTICATION_BACKENDS = (
  109. 'oscar.apps.customer.auth_backends.EmailBackend',
  110. 'django.contrib.auth.backends.ModelBackend',
  111. )
  112. AUTH_PASSWORD_VALIDATORS = [
  113. {
  114. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  115. 'OPTIONS': {
  116. 'min_length': 6,
  117. }
  118. },
  119. {
  120. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  121. },
  122. ]
  123. HAYSTACK_CONNECTIONS = {'default': {'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'}}
  124. PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']
  125. ROOT_URLCONF = 'tests._site.urls'
  126. LOGIN_REDIRECT_URL = '/accounts/'
  127. STATIC_URL = '/static/'
  128. MEDIA_URL = '/media/'
  129. PUBLIC_ROOT = location('public')
  130. MEDIA_ROOT = os.path.join(PUBLIC_ROOT, 'media')
  131. DEBUG = False
  132. SITE_ID = 1
  133. USE_TZ = 1
  134. APPEND_SLASH = True
  135. DDF_DEFAULT_DATA_FIXTURE = 'tests.dynamic_fixtures.OscarDynamicDataFixtureClass'
  136. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  137. LANGUAGE_CODE = 'en-gb'
  138. OSCAR_INITIAL_ORDER_STATUS = 'A'
  139. OSCAR_ORDER_STATUS_PIPELINE = {'A': ('B',), 'B': ()}
  140. OSCAR_INITIAL_LINE_STATUS = 'a'
  141. OSCAR_LINE_STATUS_PIPELINE = {'a': ('b', ), 'b': ()}
  142. SECRET_KEY = 'notverysecret'
  143. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
  144. FIXTURE_DIRS = [location('unit/fixtures')]