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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 has been removed)
  43. # Django 1.6: uses uidb64 to encode the user's primary key, but
  44. # but supports legacy links
  45. # Django > 1.7: used uidb64 to encode the user's primary key
  46. # see https://docs.djangoproject.com/en/dev/releases/1.6/#django-contrib-auth-password-reset-uses-base-64-encoding-of-user-pk
  47. urls.append(
  48. url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
  49. login_forbidden(auth_views.password_reset_confirm),
  50. {
  51. 'post_reset_redirect': reverse_lazy('password-reset-complete'),
  52. 'set_password_form': self.set_password_form,
  53. },
  54. name='password-reset-confirm'))
  55. if django.VERSION < (1, 7):
  56. urls.append(
  57. url(r'^password-reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
  58. login_forbidden(auth_views.password_reset_confirm_uidb36),
  59. {
  60. 'post_reset_redirect': reverse_lazy('password-reset-complete'),
  61. 'set_password_form': self.set_password_form,
  62. }))
  63. urls += [
  64. url(r'^password-reset/complete/$',
  65. login_forbidden(auth_views.password_reset_complete),
  66. name='password-reset-complete'),
  67. url(r'', include(self.promotions_app.urls)),
  68. ]
  69. return urls
  70. # 'shop' kept for legacy projects - 'application' is a better name
  71. shop = application = Shop()