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.

config.py 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # flake8: noqa, because URL syntax is more readable with long lines
  2. from django.apps import apps
  3. from django.conf import settings
  4. from django.urls import path, reverse_lazy
  5. from django.views.generic.base import RedirectView
  6. from oscar.core.application import OscarConfig
  7. from oscar.core.loading import get_class
  8. class Shop(OscarConfig):
  9. name = 'oscar'
  10. def ready(self):
  11. from django.contrib.auth.forms import SetPasswordForm
  12. self.catalogue_app = apps.get_app_config('catalogue')
  13. self.customer_app = apps.get_app_config('customer')
  14. self.basket_app = apps.get_app_config('basket')
  15. self.checkout_app = apps.get_app_config('checkout')
  16. self.search_app = apps.get_app_config('search')
  17. self.dashboard_app = apps.get_app_config('dashboard')
  18. self.offer_app = apps.get_app_config('offer')
  19. self.password_reset_form = get_class('customer.forms', 'PasswordResetForm')
  20. self.set_password_form = SetPasswordForm
  21. def get_urls(self):
  22. from django.contrib.auth import views as auth_views
  23. from oscar.views.decorators import login_forbidden
  24. urls = [
  25. path('', RedirectView.as_view(url=settings.OSCAR_HOMEPAGE), name='home'),
  26. path('catalogue/', self.catalogue_app.urls),
  27. path('basket/', self.basket_app.urls),
  28. path('checkout/', self.checkout_app.urls),
  29. path('accounts/', self.customer_app.urls),
  30. path('search/', self.search_app.urls),
  31. path('dashboard/', self.dashboard_app.urls),
  32. path('offers/', self.offer_app.urls),
  33. # Password reset - as we're using Django's default view functions,
  34. # we can't namespace these urls as that prevents
  35. # the reverse function from working.
  36. path('password-reset/',
  37. login_forbidden(
  38. auth_views.PasswordResetView.as_view(
  39. form_class=self.password_reset_form,
  40. success_url=reverse_lazy('password-reset-done'),
  41. template_name='oscar/registration/password_reset_form.html'
  42. )
  43. ),
  44. name='password-reset'),
  45. path('password-reset/done/',
  46. login_forbidden(auth_views.PasswordResetDoneView.as_view(
  47. template_name='oscar/registration/password_reset_done.html'
  48. )),
  49. name='password-reset-done'),
  50. path('password-reset/confirm/<str:uidb64>/<str:token>/',
  51. login_forbidden(
  52. auth_views.PasswordResetConfirmView.as_view(
  53. form_class=self.set_password_form,
  54. success_url=reverse_lazy('password-reset-complete'),
  55. template_name='oscar/registration/password_reset_confirm.html'
  56. )
  57. ),
  58. name='password-reset-confirm'),
  59. path('password-reset/complete/',
  60. login_forbidden(auth_views.PasswordResetCompleteView.as_view(
  61. template_name='oscar/registration/password_reset_complete.html'
  62. )),
  63. name='password-reset-complete'),
  64. ]
  65. return urls