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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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'^category/(?P<category_slug>[\w-]+(/[\w-]+)*)_(?P<pk>\d+)/$',
  17. self.category_view.as_view(), name='category'),
  18. # Legacy route for the category view
  19. url(r'^(?P<category_slug>[\w-]+(/[\w-]+)*)/$',
  20. self.category_view.as_view(), name='category'))
  21. return self.post_process_urls(urlpatterns)
  22. class ReviewsApplication(Application):
  23. name = None
  24. reviews_app = reviews_app
  25. def get_urls(self):
  26. urlpatterns = super(ReviewsApplication, self).get_urls()
  27. urlpatterns += patterns('',
  28. url(r'^(?P<product_slug>[\w-]*)_(?P<product_pk>\d+)/reviews/',
  29. include(self.reviews_app.urls)),
  30. )
  31. return self.post_process_urls(urlpatterns)
  32. class CatalogueApplication(BaseCatalogueApplication, ReviewsApplication):
  33. """
  34. Composite class combining Products with Reviews
  35. """
  36. application = CatalogueApplication()