def test_feed(self): page1, page2 = self.get_pages() post1, post2 = self.get_posts() post1.tags.add('tag 1', 'tag 2', 'tag 3', 'tag 4') post1.save() post2.tags.add('tag 6', 'tag 2', 'tag 5', 'tag 8') post2.save() post1.set_current_language('en') feed = LatestEntriesFeed() self.assertEqual(list(feed.items()), [post1]) request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=False) xml = feed(request) self.assertContains(xml, post1.get_absolute_url()) self.assertContains(xml, 'Blog articles on example.com') activate('it') post1.set_current_language('it') feed = LatestEntriesFeed() self.assertEqual(list(feed.items()), [post1]) request = self.get_page_request(page1, self.user, r'/it/blog/', lang_code='it', edit=False) xml = feed(request) self.assertContains(xml, post1.get_absolute_url()) self.assertContains(xml, 'Articoli del blog su example.com') feed = TagFeed() self.assertEqual(list(feed.items('tag-2')), [post1])
def test_feed(self): self.user.first_name = 'Admin' self.user.last_name = 'User' self.user.save() pages = self.get_pages() posts = self.get_posts() posts[0].tags.add('tag 1', 'tag 2', 'tag 3', 'tag 4') posts[0].author = self.user posts[0].save() posts[1].tags.add('tag 6', 'tag 2', 'tag 5', 'tag 8') posts[1].save() posts[0].set_current_language('en') with smart_override('en'): with switch_language(posts[0], 'en'): request = self.get_page_request( pages[1], self.user, path=posts[0].get_absolute_url()) feed = LatestEntriesFeed() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(list(feed.items()), [posts[0]]) self.reload_urlconf() xml = feed(request) self.assertContains(xml, posts[0].get_absolute_url()) self.assertContains(xml, 'Blog articles on example.com') self.assertContains(xml, 'Admin User</dc:creator>') with smart_override('it'): with switch_language(posts[0], 'it'): feed = LatestEntriesFeed() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(list(feed.items()), [posts[0]]) request = self.get_page_request( pages[1], self.user, path=posts[0].get_absolute_url()) xml = feed(request) self.assertContains(xml, posts[0].get_absolute_url()) self.assertContains(xml, 'Articoli del blog su example.com') feed = TagFeed() feed.namespace = self.app_config_1.namespace feed.config = self.app_config_1 self.assertEqual(list(feed.items('tag-2')), [posts[0]])
def test_feed(self): self.user.first_name = "Admin" self.user.last_name = "User" self.user.save() pages = self.get_pages() posts = self.get_posts() posts[0].tags.add("tag 1", "tag 2", "tag 3", "tag 4") posts[0].author = self.user posts[0].save() posts[1].tags.add("tag 6", "tag 2", "tag 5", "tag 8") posts[1].save() posts[0].set_current_language("en") with smart_override("en"): with switch_language(posts[0], "en"): request = self.get_page_request( pages[1], self.user, path=posts[0].get_absolute_url()) feed = LatestEntriesFeed() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(list(feed.items()), [posts[0]]) self.reload_urlconf() xml = feed(request) self.assertContains(xml, posts[0].get_absolute_url()) self.assertContains(xml, "Blog articles on example.com") self.assertContains(xml, "Admin User</dc:creator>") with smart_override("it"): with switch_language(posts[0], "it"): feed = LatestEntriesFeed() feed.namespace, feed.config = get_app_instance(request) self.assertEqual(list(feed.items()), [posts[0]]) request = self.get_page_request( pages[1], self.user, path=posts[0].get_absolute_url()) xml = feed(request) self.assertContains(xml, posts[0].get_absolute_url()) self.assertContains(xml, "Articoli del blog su example.com") feed = TagFeed() feed.namespace = self.app_config_1.namespace feed.config = self.app_config_1 self.assertEqual(list(feed.items("tag-2")), [posts[0]])
def get_urls(): urls = get_setting("PERMALINK_URLS") details = [] for urlconf in urls.values(): details.append( path(urlconf, PostDetailView.as_view(), name="post-detail"), ) return details detail_urls = get_urls() urlpatterns = [ path("latests/", PostListView.as_view(), name="posts-latest"), path("feed/", LatestEntriesFeed(), name="posts-latest-feed"), path("feed/fb/", FBInstantArticles(), name="posts-latest-feed-fb"), path("<int:year>/", PostArchiveView.as_view(), name="posts-archive"), path("<int:year>/<int:month>/", PostArchiveView.as_view(), name="posts-archive"), path("author/<str:username>/", AuthorEntriesView.as_view(), name="posts-author"), path("category/<str:category>/", CategoryEntriesView.as_view(), name="posts-category"), path("tag/<slug:tag>/", TaggedListView.as_view(), name="posts-tagged"), path("tag/<slug:tag>/feed/", TagFeed(), name="posts-tagged-feed"), ] + detail_urls
urls = get_setting('PERMALINK_URLS') details = [] for urlconf in urls.values(): details.append( url(urlconf, PostDetailView.as_view(), name='post-detail'), ) return details detail_urls = get_urls() urlpatterns = [ url(r'^latests/$', PostListView.as_view(), name='posts-latest'), url(r'^feed/$', LatestEntriesFeed(), name='posts-latest-feed'), url(r'^feed/fb/$', FBInstantArticles(), name='posts-latest-feed-fb'), url(r'^(?P<year>\d{4})/$', PostArchiveView.as_view(), name='posts-archive'), url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', PostArchiveView.as_view(), name='posts-archive'), url(r'^author/(?P<username>[\w\.@+-]+)/$', AuthorEntriesView.as_view(), name='posts-author'), url(r'^category/(?P<category>[\w\.@+-]+)/$', CategoryEntriesView.as_view(), name='posts-category'), url(r'^tag/(?P<tag>[-\w]+)/$', TaggedListView.as_view(), name='posts-tagged'), url(r'^tag/(?P<tag>[-\w]+)/feed/$', TagFeed(), name='posts-tagged-feed'), ] + detail_urls
urls = get_setting("PERMALINK_URLS") details = [] for urlconf in urls.values(): details.append( url(urlconf, PostDetailView.as_view(), name="post-detail"), ) return details detail_urls = get_urls() urlpatterns = [ url(r"^latests/$", PostListView.as_view(), name="posts-latest"), url(r"^feed/$", LatestEntriesFeed(), name="posts-latest-feed"), url(r"^feed/fb/$", FBInstantArticles(), name="posts-latest-feed-fb"), url(r"^(?P<year>\d{4})/$", PostArchiveView.as_view(), name="posts-archive"), url(r"^(?P<year>\d{4})/(?P<month>\d{1,2})/$", PostArchiveView.as_view(), name="posts-archive"), url(r"^author/(?P<username>[\w\.@+-]+)/$", AuthorEntriesView.as_view(), name="posts-author"), url(r"^category/(?P<category>[\w\.@+-]+)/$", CategoryEntriesView.as_view(), name="posts-category"), url(r"^tag/(?P<tag>[-\w]+)/$", TaggedListView.as_view(), name="posts-tagged"), url(r"^tag/(?P<tag>[-\w]+)/feed/$", TagFeed(), name="posts-tagged-feed"), ] + detail_urls