Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

app.py 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.offer import views as offer_views
  5. from oscar.apps.catalogue.reviews.app import application as reviews_app
  6. class BaseCatalogueApplication(Application):
  7. name = 'catalogue'
  8. detail_view = views.ProductDetailView
  9. index_view = views.ProductListView
  10. category_view = views.ProductCategoryView
  11. range_view = offer_views.RangeDetailView
  12. def get_urls(self):
  13. urlpatterns = super(BaseCatalogueApplication, self).get_urls()
  14. urlpatterns += patterns('',
  15. url(r'^$', self.index_view.as_view(), name='index'),
  16. url(r'^(?P<product_slug>[\w-]*)_(?P<pk>\d+)/$',
  17. self.detail_view.as_view(), name='detail'),
  18. url(r'^category/(?P<category_slug>[\w-]+(/[\w-]+)*)_(?P<pk>\d+)/$',
  19. self.category_view.as_view(), name='category'),
  20. url(r'^ranges/(?P<slug>[\w-]+)/$',
  21. self.range_view.as_view(), name='range'),
  22. # Legacy route for the category view
  23. url(r'^(?P<category_slug>[\w-]+(/[\w-]+)*)/$',
  24. self.category_view.as_view(), name='category'))
  25. return self.post_process_urls(urlpatterns)
  26. class ReviewsApplication(Application):
  27. name = None
  28. reviews_app = reviews_app
  29. def get_urls(self):
  30. urlpatterns = super(ReviewsApplication, self).get_urls()
  31. urlpatterns += patterns('',
  32. url(r'^(?P<product_slug>[\w-]*)_(?P<product_pk>\d+)/reviews/',
  33. include(self.reviews_app.urls)),
  34. )
  35. return self.post_process_urls(urlpatterns)
  36. class CatalogueApplication(BaseCatalogueApplication, ReviewsApplication):
  37. """
  38. Composite class combining Products with Reviews
  39. """
  40. application = CatalogueApplication()