Skip to content

Commit

Permalink
Fix FeaturedPostsPlugin get_posts method rendering all posts instead …
Browse files Browse the repository at this point in the history
…of selected ones
  • Loading branch information
protoroto committed Dec 22, 2023
1 parent 25c6d74 commit e9512ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions djangocms_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,7 @@ def copy_relations(self, oldinstance):
self.posts.set(oldinstance.posts.all())

def get_posts(self, request, published_only=True):
# if self.posts.exists():
# posts = self.post_queryset(request, published_only, selected_posts=self.posts.all())
# else:
# posts = self.post_queryset(request, published_only)
posts = self.post_queryset(request, published_only)
posts = self.post_queryset(request, published_only, selected_posts=self.posts.all())
return posts


Expand Down
6 changes: 3 additions & 3 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ def test_plugin_featured_cached(self):
plugin_nocache = add_plugin(ph, "BlogFeaturedPostsPlugin", language="en", app_config=self.app_config_1)
plugin_nocache.posts.add(posts[0])
# FIXME: Investigate the correct number of queries expected here
with self.assertNumQueries(FuzzyInt(16, 17)):
with self.assertNumQueries(FuzzyInt(15, 17)):
self.render_plugin(pages[0], "en", plugin_nocache)

with self.assertNumQueries(FuzzyInt(16, 17)):
with self.assertNumQueries(FuzzyInt(15, 17)):
self.render_plugin(pages[0], "en", plugin)

with self.assertNumQueries(FuzzyInt(16, 17)):
with self.assertNumQueries(FuzzyInt(15, 17)):
rendered = self.render_plugin(pages[0], "en", plugin)

self.assertTrue(rendered.find("<p>first line</p>") > -1)
Expand Down

0 comments on commit e9512ec

Please sign in to comment.