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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # flake8: noqa, because URL syntax is more readable with long lines
  2. from django.conf import settings
  3. from django.conf.urls import url
  4. from django.contrib.auth import views as auth_views
  5. from django.urls import reverse_lazy
  6. from oscar.core.application import Application
  7. from oscar.core.loading import get_class
  8. from oscar.views.decorators import login_forbidden
  9. class Shop(Application):
  10. name = None
  11. catalogue_app = get_class('catalogue.app', 'application')
  12. customer_app = get_class('customer.app', 'application')
  13. basket_app = get_class('basket.app', 'application')
  14. checkout_app = get_class('checkout.app', 'application')
  15. promotions_app = get_class('promotions.app', 'application')
  16. search_app = get_class('search.app', 'application')
  17. dashboard_app = get_class('dashboard.app', 'application')
  18. offer_app = get_class('offer.app', 'application')
  19. password_reset_form = get_class('customer.forms', 'PasswordResetForm')
  20. set_password_form = get_class('customer.forms', 'SetPasswordForm')
  21. def get_urls(self):
  22. urls = [
  23. url(r'^catalogue/', self.catalogue_app.urls),
  24. url(r'^basket/', self.basket_app.urls),
  25. url(r'^checkout/', self.checkout_app.urls),
  26. url(r'^accounts/', self.customer_app.urls),
  27. url(r'^search/', self.search_app.urls),
  28. url(r'^dashboard/', self.dashboard_app.urls),
  29. url(r'^offers/', self.offer_app.urls),
  30. # Password reset - as we're using Django's default view functions,
  31. # we can't namespace these urls as that prevents
  32. # the reverse function from working.
  33. url(r'^password-reset/$',
  34. login_forbidden(
  35. auth_views.PasswordResetView.as_view(
  36. form_class=self.password_reset_form,
  37. success_url=reverse_lazy('password-reset-done')
  38. )
  39. ),
  40. name='password-reset'),
  41. url(r'^password-reset/done/$',
  42. login_forbidden(auth_views.PasswordResetDoneView.as_view()),
  43. name='password-reset-done'),
  44. url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
  45. login_forbidden(
  46. auth_views.PasswordResetConfirmView.as_view(
  47. form_class=self.set_password_form,
  48. success_url=reverse_lazy('password-reset-complete')
  49. )
  50. ),
  51. name='password-reset-confirm'),
  52. url(r'^password-reset/complete/$',
  53. login_forbidden(auth_views.PasswordResetCompleteView.as_view()),
  54. name='password-reset-complete'),
  55. ]
  56. if settings.OSCAR_PROMOTIONS_ENABLED:
  57. urls.append(url(r'', self.promotions_app.urls))
  58. return urls
  59. application = Shop()