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.

app.py 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # flake8: noqa, because URL syntax is more readable with long lines
  2. import django
  3. from django.conf.urls import url, include
  4. from django.contrib.auth import views as auth_views
  5. from django.core.urlresolvers import reverse_lazy
  6. from oscar.core.application import Application
  7. from oscar.apps.customer import forms
  8. from oscar.core.loading import get_class
  9. from oscar.views.decorators import login_forbidden
  10. class Shop(Application):
  11. name = None
  12. catalogue_app = get_class('catalogue.app', 'application')
  13. customer_app = get_class('customer.app', 'application')
  14. basket_app = get_class('basket.app', 'application')
  15. checkout_app = get_class('checkout.app', 'application')
  16. promotions_app = get_class('promotions.app', 'application')
  17. search_app = get_class('search.app', 'application')
  18. dashboard_app = get_class('dashboard.app', 'application')
  19. offer_app = get_class('offer.app', 'application')
  20. password_reset_form = get_class('customer.forms', 'PasswordResetForm')
  21. set_password_form = get_class('customer.forms', 'SetPasswordForm')
  22. def get_urls(self):
  23. urls = [
  24. url(r'^catalogue/', include(self.catalogue_app.urls)),
  25. url(r'^basket/', include(self.basket_app.urls)),
  26. url(r'^checkout/', include(self.checkout_app.urls)),
  27. url(r'^accounts/', include(self.customer_app.urls)),
  28. url(r'^search/', include(self.search_app.urls)),
  29. url(r'^dashboard/', include(self.dashboard_app.urls)),
  30. url(r'^offers/', include(self.offer_app.urls)),
  31. # Password reset - as we're using Django's default view functions,
  32. # we can't namespace these urls as that prevents
  33. # the reverse function from working.
  34. url(r'^password-reset/$',
  35. login_forbidden(auth_views.password_reset),
  36. {'password_reset_form': self.password_reset_form,
  37. 'post_reset_redirect': reverse_lazy('password-reset-done')},
  38. name='password-reset'),
  39. url(r'^password-reset/done/$',
  40. login_forbidden(auth_views.password_reset_done),
  41. name='password-reset-done')]
  42. # Django <=1.5: uses uidb36 to encode the user's primary key (support
  43. # has been removed)
  44. # Django 1.6: uses uidb64 to encode the user's primary key, but
  45. # supports legacy links
  46. # Django > 1.7: used uidb64 to encode the user's primary key
  47. # see https://docs.djangoproject.com/en/dev/releases/1.6/#django-contrib-auth-password-reset-uses-base-64-encoding-of-user-pk
  48. urls.append(
  49. url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
  50. login_forbidden(auth_views.password_reset_confirm),
  51. {
  52. 'post_reset_redirect': reverse_lazy('password-reset-complete'),
  53. 'set_password_form': self.set_password_form,
  54. },
  55. name='password-reset-confirm'))
  56. if django.VERSION < (1, 7):
  57. urls.append(
  58. url(r'^password-reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
  59. login_forbidden(auth_views.password_reset_confirm_uidb36),
  60. {
  61. 'post_reset_redirect': reverse_lazy('password-reset-complete'),
  62. 'set_password_form': self.set_password_form,
  63. }))
  64. urls += [
  65. url(r'^password-reset/complete/$',
  66. login_forbidden(auth_views.password_reset_complete),
  67. name='password-reset-complete'),
  68. url(r'', include(self.promotions_app.urls)),
  69. ]
  70. return urls
  71. # 'shop' kept for legacy projects - 'application' is a better name
  72. shop = application = Shop()