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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from django.conf.urls import patterns, url, include
  2. from oscar.core.application import Application
  3. from oscar.apps.catalogue import views
  4. from oscar.apps.catalogue.reviews.app import application as reviews_app
  5. class BaseCatalogueApplication(Application):
  6. name = 'catalogue'
  7. detail_view = views.ProductDetailView
  8. index_view = views.ProductListView
  9. category_view = views.ProductCategoryView
  10. def get_urls(self):
  11. urlpatterns = super(BaseCatalogueApplication, self).get_urls()
  12. urlpatterns += patterns('',
  13. url(r'^$', self.index_view.as_view(), name='index'),
  14. url(r'^(?P<product_slug>[\w-]*)_(?P<pk>\d+)/$',
  15. self.detail_view.as_view(), name='detail'),
  16. url(r'^(?P<category_slug>[\w-]+(/[\w-]+)*)/$',
  17. self.category_view.as_view(), name='category'))
  18. return self.post_process_urls(urlpatterns)
  19. class ReviewsApplication(Application):
  20. name = None
  21. reviews_app = reviews_app
  22. def get_urls(self):
  23. urlpatterns = super(ReviewsApplication, self).get_urls()
  24. urlpatterns += patterns('',
  25. url(r'^(?P<product_slug>[\w-]*)-(?P<product_pk>\d+)/reviews/',
  26. include(self.reviews_app.urls)),
  27. )
  28. return self.post_process_urls(urlpatterns)
  29. class CatalogueApplication(BaseCatalogueApplication, ReviewsApplication):
  30. """
  31. Composite class combining Products with Reviews
  32. """
  33. application = CatalogueApplication()