Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

app.py 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. def get_urls(self):
  21. urls = [
  22. url(r'^catalogue/', include(self.catalogue_app.urls)),
  23. url(r'^basket/', include(self.basket_app.urls)),
  24. url(r'^checkout/', include(self.checkout_app.urls)),
  25. url(r'^accounts/', include(self.customer_app.urls)),
  26. url(r'^search/', include(self.search_app.urls)),
  27. url(r'^dashboard/', include(self.dashboard_app.urls)),
  28. url(r'^offers/', include(self.offer_app.urls)),
  29. # Password reset - as we're using Django's default view functions,
  30. # we can't namespace these urls as that prevents
  31. # the reverse function from working.
  32. url(r'^password-reset/$',
  33. login_forbidden(auth_views.password_reset),
  34. {'password_reset_form': forms.PasswordResetForm,
  35. 'post_reset_redirect': reverse_lazy('password-reset-done')},
  36. name='password-reset'),
  37. url(r'^password-reset/done/$',
  38. login_forbidden(auth_views.password_reset_done),
  39. name='password-reset-done')]
  40. # Django <=1.5: uses uidb36 to encode the user's primary key
  41. # Django 1.6: uses uidb64 to encode the user's primary key, but
  42. # but supports legacy links
  43. # Django > 1.7: used uidb64 to encode the user's primary key
  44. # see https://docs.djangoproject.com/en/dev/releases/1.6/#django-contrib-auth-password-reset-uses-base-64-encoding-of-user-pk
  45. if django.VERSION < (1, 6):
  46. urls.append(
  47. url(r'^password-reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
  48. login_forbidden(auth_views.password_reset_confirm),
  49. {
  50. 'post_reset_redirect': reverse_lazy('password-reset-complete'),
  51. 'set_password_form': forms.SetPasswordForm,
  52. },
  53. name='password-reset-confirm'))
  54. else:
  55. urls.append(
  56. url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
  57. login_forbidden(auth_views.password_reset_confirm),
  58. {
  59. 'post_reset_redirect': reverse_lazy('password-reset-complete'),
  60. 'set_password_form': forms.SetPasswordForm,
  61. },
  62. name='password-reset-confirm'))
  63. if django.VERSION < (1, 7):
  64. urls.append(
  65. url(r'^password-reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
  66. login_forbidden(auth_views.password_reset_confirm_uidb36),
  67. {
  68. 'post_reset_redirect': reverse_lazy('password-reset-complete'),
  69. 'set_password_form': forms.SetPasswordForm,
  70. }))
  71. urls += [
  72. url(r'^password-reset/complete/$',
  73. login_forbidden(auth_views.password_reset_complete),
  74. name='password-reset-complete'),
  75. url(r'', include(self.promotions_app.urls)),
  76. ]
  77. return urls
  78. # 'shop' kept for legacy projects - 'application' is a better name
  79. shop = application = Shop()