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 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. from django.conf.urls import url
  2. from django.contrib.auth.decorators import login_required
  3. from django.views import generic
  4. from oscar.core.application import Application
  5. from oscar.core.loading import get_class
  6. class CustomerApplication(Application):
  7. name = 'customer'
  8. summary_view = get_class('customer.views', 'AccountSummaryView')
  9. order_history_view = get_class('customer.views', 'OrderHistoryView')
  10. order_detail_view = get_class('customer.views', 'OrderDetailView')
  11. anon_order_detail_view = get_class('customer.views',
  12. 'AnonymousOrderDetailView')
  13. order_line_view = get_class('customer.views', 'OrderLineView')
  14. address_list_view = get_class('customer.views', 'AddressListView')
  15. address_create_view = get_class('customer.views', 'AddressCreateView')
  16. address_update_view = get_class('customer.views', 'AddressUpdateView')
  17. address_delete_view = get_class('customer.views', 'AddressDeleteView')
  18. address_change_status_view = get_class('customer.views',
  19. 'AddressChangeStatusView')
  20. email_list_view = get_class('customer.views', 'EmailHistoryView')
  21. email_detail_view = get_class('customer.views', 'EmailDetailView')
  22. login_view = get_class('customer.views', 'AccountAuthView')
  23. logout_view = get_class('customer.views', 'LogoutView')
  24. register_view = get_class('customer.views', 'AccountRegistrationView')
  25. profile_view = get_class('customer.views', 'ProfileView')
  26. profile_update_view = get_class('customer.views', 'ProfileUpdateView')
  27. profile_delete_view = get_class('customer.views', 'ProfileDeleteView')
  28. change_password_view = get_class('customer.views', 'ChangePasswordView')
  29. notification_inbox_view = get_class('customer.notifications.views',
  30. 'InboxView')
  31. notification_archive_view = get_class('customer.notifications.views',
  32. 'ArchiveView')
  33. notification_update_view = get_class('customer.notifications.views',
  34. 'UpdateView')
  35. notification_detail_view = get_class('customer.notifications.views',
  36. 'DetailView')
  37. alert_list_view = get_class('customer.alerts.views',
  38. 'ProductAlertListView')
  39. alert_create_view = get_class('customer.alerts.views',
  40. 'ProductAlertCreateView')
  41. alert_confirm_view = get_class('customer.alerts.views',
  42. 'ProductAlertConfirmView')
  43. alert_cancel_view = get_class('customer.alerts.views',
  44. 'ProductAlertCancelView')
  45. wishlists_add_product_view = get_class('customer.wishlists.views',
  46. 'WishListAddProduct')
  47. wishlists_list_view = get_class('customer.wishlists.views',
  48. 'WishListListView')
  49. wishlists_detail_view = get_class('customer.wishlists.views',
  50. 'WishListDetailView')
  51. wishlists_create_view = get_class('customer.wishlists.views',
  52. 'WishListCreateView')
  53. wishlists_create_with_product_view = get_class('customer.wishlists.views',
  54. 'WishListCreateView')
  55. wishlists_update_view = get_class('customer.wishlists.views',
  56. 'WishListUpdateView')
  57. wishlists_delete_view = get_class('customer.wishlists.views',
  58. 'WishListDeleteView')
  59. wishlists_remove_product_view = get_class('customer.wishlists.views',
  60. 'WishListRemoveProduct')
  61. wishlists_move_product_to_another_view = get_class(
  62. 'customer.wishlists.views', 'WishListMoveProductToAnotherWishList')
  63. def get_urls(self):
  64. urls = [
  65. # Login, logout and register doesn't require login
  66. url(r'^login/$', self.login_view.as_view(), name='login'),
  67. url(r'^logout/$', self.logout_view.as_view(), name='logout'),
  68. url(r'^register/$', self.register_view.as_view(), name='register'),
  69. url(r'^$', login_required(self.summary_view.as_view()),
  70. name='summary'),
  71. url(r'^change-password/$',
  72. login_required(self.change_password_view.as_view()),
  73. name='change-password'),
  74. # Profile
  75. url(r'^profile/$',
  76. login_required(self.profile_view.as_view()),
  77. name='profile-view'),
  78. url(r'^profile/edit/$',
  79. login_required(self.profile_update_view.as_view()),
  80. name='profile-update'),
  81. url(r'^profile/delete/$',
  82. login_required(self.profile_delete_view.as_view()),
  83. name='profile-delete'),
  84. # Order history
  85. url(r'^orders/$',
  86. login_required(self.order_history_view.as_view()),
  87. name='order-list'),
  88. url(r'^order-status/(?P<order_number>[\w-]*)/(?P<hash>\w+)/$',
  89. self.anon_order_detail_view.as_view(), name='anon-order'),
  90. url(r'^orders/(?P<order_number>[\w-]*)/$',
  91. login_required(self.order_detail_view.as_view()),
  92. name='order'),
  93. url(r'^orders/(?P<order_number>[\w-]*)/(?P<line_id>\d+)$',
  94. login_required(self.order_line_view.as_view()),
  95. name='order-line'),
  96. # Address book
  97. url(r'^addresses/$',
  98. login_required(self.address_list_view.as_view()),
  99. name='address-list'),
  100. url(r'^addresses/add/$',
  101. login_required(self.address_create_view.as_view()),
  102. name='address-create'),
  103. url(r'^addresses/(?P<pk>\d+)/$',
  104. login_required(self.address_update_view.as_view()),
  105. name='address-detail'),
  106. url(r'^addresses/(?P<pk>\d+)/delete/$',
  107. login_required(self.address_delete_view.as_view()),
  108. name='address-delete'),
  109. url(r'^addresses/(?P<pk>\d+)/'
  110. r'(?P<action>default_for_(billing|shipping))/$',
  111. login_required(self.address_change_status_view.as_view()),
  112. name='address-change-status'),
  113. # Email history
  114. url(r'^emails/$',
  115. login_required(self.email_list_view.as_view()),
  116. name='email-list'),
  117. url(r'^emails/(?P<email_id>\d+)/$',
  118. login_required(self.email_detail_view.as_view()),
  119. name='email-detail'),
  120. # Notifications
  121. # Redirect to notification inbox
  122. url(r'^notifications/$', generic.RedirectView.as_view(
  123. url='/accounts/notifications/inbox/')),
  124. url(r'^notifications/inbox/$',
  125. login_required(self.notification_inbox_view.as_view()),
  126. name='notifications-inbox'),
  127. url(r'^notifications/archive/$',
  128. login_required(self.notification_archive_view.as_view()),
  129. name='notifications-archive'),
  130. url(r'^notifications/update/$',
  131. login_required(self.notification_update_view.as_view()),
  132. name='notifications-update'),
  133. url(r'^notifications/(?P<pk>\d+)/$',
  134. login_required(self.notification_detail_view.as_view()),
  135. name='notifications-detail'),
  136. # Alerts
  137. # Alerts can be setup by anonymous users: some views do not
  138. # require login
  139. url(r'^alerts/$',
  140. login_required(self.alert_list_view.as_view()),
  141. name='alerts-list'),
  142. url(r'^alerts/create/(?P<pk>\d+)/$',
  143. self.alert_create_view.as_view(),
  144. name='alert-create'),
  145. url(r'^alerts/confirm/(?P<key>[a-z0-9]+)/$',
  146. self.alert_confirm_view.as_view(),
  147. name='alerts-confirm'),
  148. url(r'^alerts/cancel/key/(?P<key>[a-z0-9]+)/$',
  149. self.alert_cancel_view.as_view(),
  150. name='alerts-cancel-by-key'),
  151. url(r'^alerts/cancel/(?P<pk>[a-z0-9]+)/$',
  152. login_required(self.alert_cancel_view.as_view()),
  153. name='alerts-cancel-by-pk'),
  154. # Wishlists
  155. url(r'wishlists/$',
  156. login_required(self.wishlists_list_view.as_view()),
  157. name='wishlists-list'),
  158. url(r'wishlists/add/(?P<product_pk>\d+)/$',
  159. login_required(self.wishlists_add_product_view.as_view()),
  160. name='wishlists-add-product'),
  161. url(r'wishlists/(?P<key>[a-z0-9]+)/add/(?P<product_pk>\d+)/',
  162. login_required(self.wishlists_add_product_view.as_view()),
  163. name='wishlists-add-product'),
  164. url(r'wishlists/create/$',
  165. login_required(self.wishlists_create_view.as_view()),
  166. name='wishlists-create'),
  167. url(r'wishlists/create/with-product/(?P<product_pk>\d+)/$',
  168. login_required(self.wishlists_create_view.as_view()),
  169. name='wishlists-create-with-product'),
  170. # Wishlists can be publicly shared, no login required
  171. url(r'wishlists/(?P<key>[a-z0-9]+)/$',
  172. self.wishlists_detail_view.as_view(), name='wishlists-detail'),
  173. url(r'wishlists/(?P<key>[a-z0-9]+)/update/$',
  174. login_required(self.wishlists_update_view.as_view()),
  175. name='wishlists-update'),
  176. url(r'wishlists/(?P<key>[a-z0-9]+)/delete/$',
  177. login_required(self.wishlists_delete_view.as_view()),
  178. name='wishlists-delete'),
  179. url(r'wishlists/(?P<key>[a-z0-9]+)/lines/(?P<line_pk>\d+)/delete/',
  180. login_required(self.wishlists_remove_product_view.as_view()),
  181. name='wishlists-remove-product'),
  182. url(r'wishlists/(?P<key>[a-z0-9]+)/products/(?P<product_pk>\d+)/'
  183. r'delete/',
  184. login_required(self.wishlists_remove_product_view.as_view()),
  185. name='wishlists-remove-product'),
  186. url(r'wishlists/(?P<key>[a-z0-9]+)/lines/(?P<line_pk>\d+)/move-to/'
  187. r'(?P<to_key>[a-z0-9]+)/$',
  188. login_required(self.wishlists_move_product_to_another_view
  189. .as_view()),
  190. name='wishlists-move-product-to-another')]
  191. return self.post_process_urls(urls)
  192. application = CustomerApplication()