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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. import os
  2. import environ
  3. import oscar
  4. env = environ.Env()
  5. # WSGI_APPLICATION = "sandbox.wsgi.application"
  6. # ASGI_APPLICATION = "sandbox.asgi.application"
  7. # Path helper
  8. location = lambda x: os.path.join(
  9. os.path.dirname(os.path.realpath(__file__)), x)
  10. DEBUG = env.bool('DEBUG', default=True)
  11. DEBUG = True
  12. ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['localhost', '127.0.0.1'])
  13. ALLOWED_HOSTS = [*ALLOWED_HOSTS,"dev.edanflor.com"]
  14. CSRF_TRUSTED_ORIGINS =["https://*.edanflor.com"]
  15. EMAIL_SUBJECT_PREFIX = '[Oscar sandbox] '
  16. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  17. # Use a Sqlite database by default
  18. DATABASES = {
  19. 'default': {
  20. 'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.sqlite3'),
  21. 'NAME': os.environ.get('DATABASE_NAME', location('db.sqlite')),
  22. 'USER': os.environ.get('DATABASE_USER', None),
  23. 'PASSWORD': os.environ.get('DATABASE_PASSWORD', None),
  24. 'HOST': os.environ.get('DATABASE_HOST', None),
  25. 'PORT': os.environ.get('DATABASE_PORT', None),
  26. 'ATOMIC_REQUESTS': True
  27. }
  28. }
  29. CACHES = {
  30. 'default': env.cache(default='locmemcache://'),
  31. }
  32. # Local time zone for this installation. Choices can be found here:
  33. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  34. # although not all choices may be available on all operating systems.
  35. # On Unix systems, a value of None will cause Django to use the same
  36. # timezone as the operating system.
  37. USE_TZ = True
  38. TIME_ZONE = 'Europe/London'
  39. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
  40. # Language code for this installation. All choices can be found here:
  41. # http://www.i18nguy.com/unicode/language-identifiers.html
  42. LANGUAGE_CODE = 'en-gb'
  43. # Includes all languages that have >50% coverage in Transifex
  44. # Taken from Django's default setting for LANGUAGES
  45. gettext_noop = lambda s: s
  46. LANGUAGES = (
  47. ('ar', gettext_noop('Arabic')),
  48. ('ca', gettext_noop('Catalan')),
  49. ('cs', gettext_noop('Czech')),
  50. ('da', gettext_noop('Danish')),
  51. ('de', gettext_noop('German')),
  52. ('en-gb', gettext_noop('British English')),
  53. ('el', gettext_noop('Greek')),
  54. ('es', gettext_noop('Spanish')),
  55. ('fi', gettext_noop('Finnish')),
  56. ('fr', gettext_noop('French')),
  57. ('it', gettext_noop('Italian')),
  58. ('ko', gettext_noop('Korean')),
  59. ('nl', gettext_noop('Dutch')),
  60. ('pl', gettext_noop('Polish')),
  61. ('pt', gettext_noop('Portuguese')),
  62. ('pt-br', gettext_noop('Brazilian Portuguese')),
  63. ('ro', gettext_noop('Romanian')),
  64. ('ru', gettext_noop('Russian')),
  65. ('sk', gettext_noop('Slovak')),
  66. ('uk', gettext_noop('Ukrainian')),
  67. ('zh-cn', gettext_noop('Simplified Chinese')),
  68. )
  69. SITE_ID = 1
  70. # If you set this to False, Django will make some optimizations so as not
  71. # to load the internationalization machinery.
  72. USE_I18N = True
  73. # If you set this to False, Django will not format dates, numbers and
  74. # calendars according to the current locale
  75. USE_L10N = True
  76. # Absolute path to the directory that holds media.
  77. # Example: "/home/media/media.lawrence.com/"
  78. MEDIA_ROOT = location("public/media")
  79. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  80. # trailing slash if there is a path component (optional in other cases).
  81. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  82. MEDIA_URL = '/media/'
  83. STATIC_URL = '/static/'
  84. STATIC_ROOT = location('public/static')
  85. STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  86. STATICFILES_DIRS = (
  87. location('static/'),
  88. )
  89. STATICFILES_FINDERS = (
  90. 'django.contrib.staticfiles.finders.FileSystemFinder',
  91. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  92. )
  93. # Default primary key field type
  94. # https://docs.djangoproject.com/en/dev/ref/settings/#default-auto-field
  95. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  96. # Make this unique, and don't share it with anybody.
  97. SECRET_KEY = env.str('SECRET_KEY', default='UajFCuyjDKmWHe29neauXzHi9eZoRXr6RMbT5JyAdPiACBP6Cra2')
  98. TEMPLATES = [
  99. {
  100. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  101. 'DIRS': [
  102. location('templates'),
  103. ],
  104. 'OPTIONS': {
  105. 'loaders': [
  106. 'django.template.loaders.filesystem.Loader',
  107. 'django.template.loaders.app_directories.Loader',
  108. ],
  109. 'context_processors': [
  110. 'django.contrib.auth.context_processors.auth',
  111. 'django.template.context_processors.request',
  112. 'django.template.context_processors.debug',
  113. 'django.template.context_processors.i18n',
  114. 'django.template.context_processors.media',
  115. 'django.template.context_processors.static',
  116. 'django.contrib.messages.context_processors.messages',
  117. # Oscar specific
  118. 'oscar.apps.search.context_processors.search_form',
  119. 'oscar.apps.communication.notifications.context_processors.notifications',
  120. 'oscar.apps.checkout.context_processors.checkout',
  121. 'oscar.core.context_processors.metadata',
  122. ],
  123. 'debug': DEBUG,
  124. }
  125. }
  126. ]
  127. MIDDLEWARE = [
  128. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  129. 'django.middleware.security.SecurityMiddleware',
  130. 'whitenoise.middleware.WhiteNoiseMiddleware',
  131. 'django.contrib.sessions.middleware.SessionMiddleware',
  132. 'django.middleware.csrf.CsrfViewMiddleware',
  133. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  134. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  135. 'django.contrib.messages.middleware.MessageMiddleware',
  136. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  137. # Allow languages to be selected
  138. 'django.middleware.locale.LocaleMiddleware',
  139. 'django.middleware.http.ConditionalGetMiddleware',
  140. 'django.middleware.common.CommonMiddleware',
  141. # Ensure a valid basket is added to the request instance for every request
  142. 'oscar.apps.basket.middleware.BasketMiddleware',
  143. ]
  144. ROOT_URLCONF = 'urls'
  145. # A sample logging configuration. The only tangible logging
  146. # performed by this configuration is to send an email to
  147. # the site admins on every HTTP 500 error.
  148. # See http://docs.djangoproject.com/en/dev/topics/logging for
  149. # more details on how to customize your logging configuration.
  150. LOGGING = {
  151. 'version': 1,
  152. 'disable_existing_loggers': True,
  153. 'formatters': {
  154. 'verbose': {
  155. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  156. },
  157. 'simple': {
  158. 'format': '[%(asctime)s] %(message)s'
  159. },
  160. },
  161. 'root': {
  162. 'level': 'DEBUG',
  163. 'handlers': ['console'],
  164. },
  165. 'handlers': {
  166. 'null': {
  167. 'level': 'DEBUG',
  168. 'class': 'logging.NullHandler',
  169. },
  170. 'console': {
  171. 'level': 'DEBUG',
  172. 'class': 'logging.StreamHandler',
  173. 'formatter': 'simple'
  174. },
  175. },
  176. 'loggers': {
  177. 'oscar': {
  178. 'level': 'DEBUG',
  179. 'propagate': True,
  180. },
  181. 'oscar.catalogue.import': {
  182. 'handlers': ['console'],
  183. 'level': 'INFO',
  184. 'propagate': False,
  185. },
  186. 'oscar.alerts': {
  187. 'handlers': ['null'],
  188. 'level': 'INFO',
  189. 'propagate': False,
  190. },
  191. # Django loggers
  192. 'django': {
  193. 'handlers': ['null'],
  194. 'propagate': True,
  195. 'level': 'INFO',
  196. },
  197. 'django.request': {
  198. 'handlers': ['console'],
  199. 'level': 'ERROR',
  200. 'propagate': True,
  201. },
  202. 'django.db.backends': {
  203. 'level': 'WARNING',
  204. 'propagate': True,
  205. },
  206. 'django.security.DisallowedHost': {
  207. 'handlers': ['null'],
  208. 'propagate': False,
  209. },
  210. # Third party
  211. 'raven': {
  212. 'level': 'DEBUG',
  213. 'handlers': ['console'],
  214. 'propagate': False,
  215. },
  216. 'sorl.thumbnail': {
  217. 'handlers': ['console'],
  218. 'propagate': True,
  219. 'level': 'INFO',
  220. },
  221. }
  222. }
  223. INSTALLED_APPS = [
  224. 'django.contrib.admin',
  225. 'django.contrib.auth',
  226. 'django.contrib.contenttypes',
  227. 'django.contrib.sessions',
  228. 'django.contrib.messages',
  229. 'django.contrib.staticfiles',
  230. 'django.contrib.sites',
  231. 'django.contrib.flatpages',
  232. 'oscar.config.Shop',
  233. 'oscar.apps.analytics.apps.AnalyticsConfig',
  234. 'oscar.apps.checkout.apps.CheckoutConfig',
  235. 'oscar.apps.address.apps.AddressConfig',
  236. 'oscar.apps.shipping.apps.ShippingConfig',
  237. 'oscar.apps.catalogue.apps.CatalogueConfig',
  238. 'oscar.apps.catalogue.reviews.apps.CatalogueReviewsConfig',
  239. 'oscar.apps.communication.apps.CommunicationConfig',
  240. 'oscar.apps.partner.apps.PartnerConfig',
  241. 'oscar.apps.basket.apps.BasketConfig',
  242. 'oscar.apps.payment.apps.PaymentConfig',
  243. 'oscar.apps.offer.apps.OfferConfig',
  244. 'oscar.apps.order.apps.OrderConfig',
  245. 'oscar.apps.customer.apps.CustomerConfig',
  246. 'oscar.apps.search.apps.SearchConfig',
  247. 'oscar.apps.voucher.apps.VoucherConfig',
  248. 'oscar.apps.wishlists.apps.WishlistsConfig',
  249. 'oscar.apps.dashboard.apps.DashboardConfig',
  250. 'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',
  251. 'oscar.apps.dashboard.users.apps.UsersDashboardConfig',
  252. 'oscar.apps.dashboard.orders.apps.OrdersDashboardConfig',
  253. 'oscar.apps.dashboard.catalogue.apps.CatalogueDashboardConfig',
  254. 'oscar.apps.dashboard.offers.apps.OffersDashboardConfig',
  255. 'oscar.apps.dashboard.partners.apps.PartnersDashboardConfig',
  256. 'oscar.apps.dashboard.pages.apps.PagesDashboardConfig',
  257. 'oscar.apps.dashboard.ranges.apps.RangesDashboardConfig',
  258. 'oscar.apps.dashboard.reviews.apps.ReviewsDashboardConfig',
  259. 'oscar.apps.dashboard.vouchers.apps.VouchersDashboardConfig',
  260. 'oscar.apps.dashboard.communications.apps.CommunicationsDashboardConfig',
  261. 'oscar.apps.dashboard.shipping.apps.ShippingDashboardConfig',
  262. # 3rd-party apps that Oscar depends on
  263. 'widget_tweaks',
  264. 'haystack',
  265. 'treebeard',
  266. 'sorl.thumbnail',
  267. 'easy_thumbnails',
  268. 'django_tables2',
  269. # Django apps that the sandbox depends on
  270. 'django.contrib.sitemaps',
  271. # 3rd-party apps that the sandbox depends on
  272. 'django_extensions',
  273. 'debug_toolbar',
  274. # "san"
  275. ]
  276. # Add Oscar's custom auth backend so users can sign in using their email
  277. # address.
  278. AUTHENTICATION_BACKENDS = (
  279. 'oscar.apps.customer.auth_backends.EmailBackend',
  280. 'django.contrib.auth.backends.ModelBackend',
  281. )
  282. AUTH_PASSWORD_VALIDATORS = [
  283. {
  284. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  285. 'OPTIONS': {
  286. 'min_length': 9,
  287. }
  288. },
  289. {
  290. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  291. },
  292. ]
  293. LOGIN_REDIRECT_URL = '/'
  294. APPEND_SLASH = True
  295. # ====================
  296. # Messages contrib app
  297. # ====================
  298. from django.contrib.messages import constants as messages
  299. MESSAGE_TAGS = {
  300. messages.ERROR: 'danger'
  301. }
  302. HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
  303. # Woosh settings
  304. HAYSTACK_CONNECTIONS = {
  305. 'default': {
  306. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  307. 'PATH': location('whoosh_index'),
  308. 'INCLUDE_SPELLING': True,
  309. },
  310. }
  311. # Here's a sample Haystack config for Solr 6.x (which is recommended)
  312. # HAYSTACK_CONNECTIONS = {
  313. # 'default': {
  314. # 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  315. # 'URL': 'http://127.0.0.1:8983/solr/sandbox',
  316. # 'ADMIN_URL': 'http://127.0.0.1:8983/solr/admin/cores',
  317. # 'INCLUDE_SPELLING': True,
  318. # }
  319. # }
  320. # =============
  321. # Debug Toolbar
  322. # =============
  323. INTERNAL_IPS = ['127.0.0.1', '::1']
  324. # ==============
  325. # Oscar settings
  326. # ==============
  327. from oscar.defaults import *
  328. # Meta
  329. # ====
  330. OSCAR_SHOP_TAGLINE = 'Sandbox'
  331. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  332. OSCAR_ALLOW_ANON_CHECKOUT = True
  333. # Order processing
  334. # ================
  335. # Sample order/line status settings. This is quite simplistic. It's like you'll
  336. # want to override the set_status method on the order object to do more
  337. # sophisticated things.
  338. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  339. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  340. # This dict defines the new order statuses than an order can move to
  341. OSCAR_ORDER_STATUS_PIPELINE = {
  342. 'Pending': ('Being processed', 'Cancelled',),
  343. 'Being processed': ('Complete', 'Cancelled',),
  344. 'Cancelled': (),
  345. 'Complete': (),
  346. }
  347. # This dict defines the line statuses that will be set when an order's status
  348. # is changed
  349. OSCAR_ORDER_STATUS_CASCADE = {
  350. 'Being processed': 'Being processed',
  351. 'Cancelled': 'Cancelled',
  352. 'Complete': 'Shipped',
  353. }
  354. # Sorl
  355. # ====
  356. THUMBNAIL_DEBUG = DEBUG
  357. THUMBNAIL_KEY_PREFIX = 'oscar-sandbox'
  358. THUMBNAIL_KVSTORE = env(
  359. 'THUMBNAIL_KVSTORE',
  360. default='sorl.thumbnail.kvstores.cached_db_kvstore.KVStore')
  361. THUMBNAIL_REDIS_URL = env('THUMBNAIL_REDIS_URL', default=None)
  362. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  363. # serialize Models. We should resolve this by extending the
  364. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  365. # in tests/config.py
  366. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  367. # Security
  368. SECURE_SSL_REDIRECT = env.bool('SECURE_SSL_REDIRECT', default=False)
  369. SECURE_HSTS_SECONDS = env.int('SECURE_HSTS_SECONDS', default=0)
  370. SECURE_CONTENT_TYPE_NOSNIFF = True
  371. SECURE_BROWSER_XSS_FILTER = True
  372. # Try and import local settings which can be used to override any of the above.
  373. try:
  374. from settings_local import *
  375. except ImportError:
  376. pass