您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

settings.py 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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', 'django.db.backends.postgresql'),
  10. 'NAME': os.environ.get('DATABASE_NAME', 'oscar'),
  11. 'USER': os.environ.get('DATABASE_USER', None),
  12. 'PASSWORD': os.environ.get('DATABASE_PASSWORD', None),
  13. 'HOST': os.environ.get('DATABASE_HOST', ''),
  14. 'PORT': os.environ.get('DATABASE_PORT', 5432),
  15. }
  16. }
  17. INSTALLED_APPS = [
  18. 'django.contrib.admin',
  19. 'django.contrib.auth',
  20. 'django.contrib.contenttypes',
  21. 'django.contrib.sessions',
  22. 'django.contrib.staticfiles',
  23. 'django.contrib.sites',
  24. 'django.contrib.flatpages',
  25. 'oscar.config.Shop',
  26. 'oscar.apps.analytics.apps.AnalyticsConfig',
  27. 'oscar.apps.checkout.apps.CheckoutConfig',
  28. 'oscar.apps.address.apps.AddressConfig',
  29. 'oscar.apps.shipping.apps.ShippingConfig',
  30. 'oscar.apps.catalogue.apps.CatalogueConfig',
  31. 'oscar.apps.catalogue.reviews.apps.CatalogueReviewsConfig',
  32. 'oscar.apps.communication.apps.CommunicationConfig',
  33. 'oscar.apps.partner.apps.PartnerConfig',
  34. 'oscar.apps.basket.apps.BasketConfig',
  35. 'oscar.apps.payment.apps.PaymentConfig',
  36. 'oscar.apps.offer.apps.OfferConfig',
  37. 'oscar.apps.order.apps.OrderConfig',
  38. 'oscar.apps.customer.apps.CustomerConfig',
  39. 'oscar.apps.search.apps.SearchConfig',
  40. 'oscar.apps.voucher.apps.VoucherConfig',
  41. 'oscar.apps.wishlists.apps.WishlistsConfig',
  42. 'oscar.apps.dashboard.apps.DashboardConfig',
  43. 'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',
  44. 'oscar.apps.dashboard.users.apps.UsersDashboardConfig',
  45. 'oscar.apps.dashboard.orders.apps.OrdersDashboardConfig',
  46. 'oscar.apps.dashboard.catalogue.apps.CatalogueDashboardConfig',
  47. 'oscar.apps.dashboard.offers.apps.OffersDashboardConfig',
  48. 'oscar.apps.dashboard.partners.apps.PartnersDashboardConfig',
  49. 'oscar.apps.dashboard.pages.apps.PagesDashboardConfig',
  50. 'oscar.apps.dashboard.ranges.apps.RangesDashboardConfig',
  51. 'oscar.apps.dashboard.reviews.apps.ReviewsDashboardConfig',
  52. 'oscar.apps.dashboard.vouchers.apps.VouchersDashboardConfig',
  53. 'oscar.apps.dashboard.communications.apps.CommunicationsDashboardConfig',
  54. 'oscar.apps.dashboard.shipping.apps.ShippingDashboardConfig',
  55. # 3rd-party apps that oscar depends on
  56. 'widget_tweaks',
  57. 'haystack',
  58. 'treebeard',
  59. 'sorl.thumbnail',
  60. 'easy_thumbnails',
  61. 'django_tables2',
  62. # Contains models we need for testing
  63. 'tests._site.model_tests_app',
  64. 'tests._site.myauth',
  65. ]
  66. # Use a custom partner app to test overriding models. I can't find a way of
  67. # doing this on a per-test basis, so I'm using a global change.
  68. partner_app_idx = INSTALLED_APPS.index('oscar.apps.partner.apps.PartnerConfig')
  69. INSTALLED_APPS[partner_app_idx] = 'tests._site.apps.partner.apps.PartnerConfig'
  70. customer_app_idx = INSTALLED_APPS.index('oscar.apps.customer.apps.CustomerConfig')
  71. INSTALLED_APPS[customer_app_idx] = 'tests._site.apps.customer.apps.CustomerConfig'
  72. catalogue_app_idx = INSTALLED_APPS.index('oscar.apps.catalogue.apps.CatalogueConfig')
  73. INSTALLED_APPS[catalogue_app_idx] = 'tests._site.apps.catalogue.apps.CatalogueConfig'
  74. dashboard_app_idx = INSTALLED_APPS.index('oscar.apps.dashboard.apps.DashboardConfig')
  75. INSTALLED_APPS[dashboard_app_idx] = 'tests._site.apps.dashboard.apps.DashboardConfig'
  76. checkout_app_idx = INSTALLED_APPS.index('oscar.apps.checkout.apps.CheckoutConfig')
  77. INSTALLED_APPS[checkout_app_idx] = 'tests._site.apps.checkout.apps.CheckoutConfig'
  78. AUTH_USER_MODEL = 'myauth.User'
  79. TEMPLATES = [
  80. {
  81. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  82. 'DIRS': [
  83. location('_site/templates'),
  84. ],
  85. 'OPTIONS': {
  86. 'loaders': [
  87. ('django.template.loaders.cached.Loader', [
  88. 'django.template.loaders.filesystem.Loader',
  89. 'django.template.loaders.app_directories.Loader',
  90. ]),
  91. ],
  92. 'context_processors': [
  93. 'django.contrib.auth.context_processors.auth',
  94. 'django.template.context_processors.request',
  95. 'django.template.context_processors.debug',
  96. 'django.template.context_processors.i18n',
  97. 'django.template.context_processors.media',
  98. 'django.template.context_processors.static',
  99. 'django.contrib.messages.context_processors.messages',
  100. 'oscar.apps.search.context_processors.search_form',
  101. 'oscar.apps.communication.notifications.context_processors.notifications',
  102. 'oscar.apps.checkout.context_processors.checkout',
  103. 'oscar.core.context_processors.metadata',
  104. ]
  105. }
  106. }
  107. ]
  108. MIDDLEWARE = [
  109. 'django.middleware.common.CommonMiddleware',
  110. 'django.contrib.sessions.middleware.SessionMiddleware',
  111. 'django.middleware.csrf.CsrfViewMiddleware',
  112. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  113. 'django.contrib.messages.middleware.MessageMiddleware',
  114. 'oscar.apps.basket.middleware.BasketMiddleware',
  115. ]
  116. AUTHENTICATION_BACKENDS = (
  117. 'oscar.apps.customer.auth_backends.EmailBackend',
  118. 'django.contrib.auth.backends.ModelBackend',
  119. )
  120. AUTH_PASSWORD_VALIDATORS = [
  121. {
  122. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  123. 'OPTIONS': {
  124. 'min_length': 6,
  125. }
  126. },
  127. {
  128. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  129. },
  130. ]
  131. HAYSTACK_CONNECTIONS = {'default': {'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'}}
  132. PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']
  133. ROOT_URLCONF = 'tests._site.urls'
  134. LOGIN_REDIRECT_URL = '/accounts/'
  135. STATIC_URL = '/static/'
  136. MEDIA_URL = '/media/'
  137. PUBLIC_ROOT = location('public')
  138. MEDIA_ROOT = os.path.join(PUBLIC_ROOT, 'media')
  139. DEBUG = False
  140. SITE_ID = 1
  141. USE_TZ = 1
  142. APPEND_SLASH = True
  143. DDF_DEFAULT_DATA_FIXTURE = 'tests.dynamic_fixtures.OscarDynamicDataFixtureClass'
  144. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  145. LANGUAGE_CODE = 'en-gb'
  146. OSCAR_INITIAL_ORDER_STATUS = 'A'
  147. OSCAR_ORDER_STATUS_PIPELINE = {'A': ('B',), 'B': ()}
  148. OSCAR_INITIAL_LINE_STATUS = 'a'
  149. OSCAR_LINE_STATUS_PIPELINE = {'a': ('b', ), 'b': ()}
  150. SECRET_KEY = 'notverysecret'
  151. # Removed in Django 4.0, then we need to update the hashes to SHA-256 in tests/integration/order/test_models.py
  152. DEFAULT_HASHING_ALGORITHM = 'sha1'
  153. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
  154. FIXTURE_DIRS = [location('unit/fixtures')]