from django.conf.urls import patterns, url, include from oscar.core.application import Application from oscar.apps.catalogue.views import ProductDetailView, ProductListView, ProductCategoryView from oscar.apps.catalogue.reviews.app import application as reviews_app class BaseCatalogueApplication(Application): name = 'catalogue' detail_view = ProductDetailView index_view = ProductListView category_view = ProductCategoryView def get_urls(self): urlpatterns = super(BaseCatalogueApplication, self).get_urls() urlpatterns += patterns('', url(r'^$', self.index_view.as_view(), name='index'), url(r'^(?P[\w-]*)_(?P\d+)/$', self.detail_view.as_view(), name='detail'), url(r'^(?P[\w-]+(/[\w-]+)*)/$', self.category_view.as_view(), name='category') ) return self.post_process_urls(urlpatterns) class ReviewsApplication(Application): name = None reviews_app = reviews_app def get_urls(self): urlpatterns = super(ReviewsApplication, self).get_urls() urlpatterns += patterns('', url(r'^(?P[\w-]*)-(?P\d+)/reviews/', include(self.reviews_app.urls)), ) return self.post_process_urls(urlpatterns) class CatalogueApplication(BaseCatalogueApplication, ReviewsApplication): """ Composite class combining Products with Reviews """ application = CatalogueApplication()