Beispiel #1
0
    def test_category_feed(self):
        with override(self.category1.get_current_language()):
            article = self.create_article()
            article.categories.add(self.category1)
            different_category_article = self.create_article()
            different_category_article.categories.add(self.category2)

            self.request.current_page = self.page
            self.request.path = reverse(
                '{0}:article-list-by-category-feed'.format(
                    self.app_config.namespace),
                args=[self.category1.slug])

            feed = CategoryFeed()(self.request, self.category1.slug)

            self.assertContains(feed, article.title)
            self.assertNotContains(feed, different_category_article.title)
    def test_category_feed(self):
        lang = self.category1.get_current_language()
        with override(lang):
            article = self.create_article()
            article.categories.add(self.category1)
            different_category_article = self.create_article()
            different_category_article.categories.add(self.category2)
            url = reverse('{0}:article-list-by-category-feed'.format(
                self.app_config.namespace),
                          args=[self.category1.slug])
            self.request = self.get_request(lang, url)
            if getattr(self.request, 'current_page', None) is None:
                self.request.current_page = self.page

            feed = CategoryFeed()(self.request, self.category1.slug)

            self.assertContains(feed, article.title)
            self.assertNotContains(feed, different_category_article.title)
Beispiel #3
0
    MonthArticleList,
    TagArticleList,
    YearArticleList,
)

urlpatterns = [
    url(r'^$', ArticleList.as_view(), name='article-list'),
    url(r'^feed/$', LatestArticlesFeed(), name='article-list-feed'),
    url(r'^search/$',
        ArticleSearchResultsList.as_view(),
        name='article-search'),
    url(r'^(?P<category>\w[-\w]*)/$',
        CategoryArticleList.as_view(),
        name='article-list-by-category'),
    url(r'^(?P<category>\w[-\w]*)/feed/$',
        CategoryFeed(),
        name='article-list-by-category-feed'),
    #url(r'^(?P<slug>\w[-\w]*)/$',
    #ArticleDetail.as_view(), name='article-detail'),
    url(r'^archive/(?P<year>\d{4})/$',
        YearArticleList.as_view(),
        name='article-list-by-year'),
    url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$',
        MonthArticleList.as_view(),
        name='article-list-by-month'),
    url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
        DayArticleList.as_view(),
        name='article-list-by-day'),

    # Various permalink styles that we support
    # ----------------------------------------
Beispiel #4
0
    # ----------------------------------------
    # This supports permalinks with <article_pk>
    # NOTE: We cannot support /year/month/pk, /year/pk, or /pk, since these
    # patterns collide with the list/archive views, which we'd prefer to
    # continue to support.
    url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
        ArticleDetail.as_view(), name='article-detail'),
    # These support permalinks with <article_slug>
    url(r'^(?P<slug>\w[-\w]*)/$',
        ArticleDetail.as_view(), name='article-detail'),
    url(r'^(?P<year>\d{4})/(?P<slug>\w[-\w]*)/$',
        ArticleDetail.as_view(), name='article-detail'),
    url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<slug>\w[-\w]*)/$',
        ArticleDetail.as_view(), name='article-detail'),
    url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$',  # flake8: noqa
        ArticleDetail.as_view(), name='article-detail'),

    url(r'^author/(?P<author>\w[-\w]*)/$',
        AuthorArticleList.as_view(), name='article-list-by-author'),

    url(r'^category/(?P<category>\w[-\w]*)/$',
        CategoryArticleList.as_view(), name='article-list-by-category'),
    url(r'^category/(?P<category>\w[-\w]*)/feed/$',
        CategoryFeed(), name='article-list-by-category-feed'),

    url(r'^tag/(?P<tag>\w[-\w]*)/$',
        TagArticleList.as_view(), name='article-list-by-tag'),
    url(r'^tag/(?P<tag>\w[-\w]*)/feed/$',
        TagFeed(), name='article-list-by-tag-feed'),
]