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

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from django.conf.urls import patterns, url, include
  2. from oscar.core.application import Application
  3. from oscar.apps.catalogue.views import ProductDetailView, ProductListView, ProductCategoryView
  4. from oscar.apps.catalogue.reviews.app import application as reviews_app
  5. class BaseCatalogueApplication(Application):
  6. name = 'catalogue'
  7. detail_view = ProductDetailView
  8. index_view = ProductListView
  9. category_view = 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. )
  19. return self.post_process_urls(urlpatterns)
  20. class ReviewsApplication(Application):
  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/', include(self.reviews_app.urls)),
  26. )
  27. return self.post_process_urls(urlpatterns)
  28. class CatalogueApplication(BaseCatalogueApplication, ReviewsApplication):
  29. """
  30. Composite class combining Products with Reviews
  31. """
  32. application = CatalogueApplication()