Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

config.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import os
  2. import django
  3. from django.conf import settings, global_settings
  4. from oscar import OSCAR_CORE_APPS, OSCAR_MAIN_TEMPLATE_DIR
  5. def configure():
  6. if not settings.configured:
  7. from oscar.defaults import OSCAR_SETTINGS
  8. # Helper function to extract absolute path
  9. location = lambda x: os.path.join(
  10. os.path.dirname(os.path.realpath(__file__)), x)
  11. test_settings = {
  12. 'DATABASES': {
  13. 'default': {
  14. 'ENGINE': 'django.db.backends.sqlite3',
  15. 'NAME': ':memory:',
  16. },
  17. },
  18. 'INSTALLED_APPS': [
  19. 'django.contrib.auth',
  20. 'django.contrib.admin',
  21. 'django.contrib.contenttypes',
  22. 'django.contrib.sessions',
  23. 'django.contrib.sites',
  24. 'django.contrib.flatpages',
  25. 'django.contrib.staticfiles',
  26. 'sorl.thumbnail',
  27. 'compressor',
  28. ] + OSCAR_CORE_APPS,
  29. 'TEMPLATE_CONTEXT_PROCESSORS': (
  30. "django.contrib.auth.context_processors.auth",
  31. "django.core.context_processors.request",
  32. "django.core.context_processors.debug",
  33. "django.core.context_processors.i18n",
  34. "django.core.context_processors.media",
  35. "django.core.context_processors.static",
  36. "django.contrib.messages.context_processors.messages",
  37. 'oscar.apps.search.context_processors.search_form',
  38. 'oscar.apps.customer.notifications.context_processors.notifications',
  39. 'oscar.apps.promotions.context_processors.promotions',
  40. 'oscar.apps.checkout.context_processors.checkout',
  41. 'oscar.core.context_processors.metadata',
  42. ),
  43. 'TEMPLATE_DIRS': (
  44. location('templates'),
  45. OSCAR_MAIN_TEMPLATE_DIR,
  46. ),
  47. 'MIDDLEWARE_CLASSES': global_settings.MIDDLEWARE_CLASSES + (
  48. 'oscar.apps.basket.middleware.BasketMiddleware',
  49. ),
  50. 'AUTHENTICATION_BACKENDS': (
  51. 'oscar.apps.customer.auth_backends.Emailbackend',
  52. 'django.contrib.auth.backends.ModelBackend',
  53. ),
  54. 'HAYSTACK_CONNECTIONS': {
  55. 'default': {
  56. 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
  57. }
  58. },
  59. 'PASSWORD_HASHERS': ['django.contrib.auth.hashers.MD5PasswordHasher'],
  60. 'ROOT_URLCONF': 'tests._site.urls',
  61. 'LOGIN_REDIRECT_URL': '/accounts/',
  62. 'STATIC_URL': '/static/',
  63. 'COMPRESS_ENABLED': False,
  64. 'ADMINS': ('admin@example.com',),
  65. 'DEBUG': False,
  66. 'SITE_ID': 1,
  67. 'APPEND_SLASH': True,
  68. 'DDF_DEFAULT_DATA_FIXTURE': 'tests.dynamic_fixtures.OscarDynamicDataFixtureClass',
  69. 'SESSION_SERIALIZER': 'django.contrib.sessions.serializers.PickleSerializer',
  70. }
  71. if django.VERSION >= (1, 5):
  72. test_settings['INSTALLED_APPS'] += ['tests._site.myauth', ]
  73. test_settings['AUTH_USER_MODEL'] = 'myauth.User'
  74. test_settings.update(OSCAR_SETTINGS)
  75. settings.configure(**test_settings)