Skip to content

Commit

Permalink
Fix AuthorEntriesPlugin.copy_relations
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Jan 13, 2019
1 parent 54bd265 commit c148331
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion djangocms_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ def __str__(self):
return force_text(_('%s latest articles by author') % self.latest_posts)

def copy_relations(self, oldinstance):
self.authors = oldinstance.authors.all()
try:
self.authors.set(oldinstance.authors.all())
except AttributeError:
self.authors = oldinstance.authors.all()

def get_posts(self, request, published_only=True):
posts = self.post_queryset(request, published_only)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_templates(self):
self.app_config_1.save()


class PluginTest2(BaseTest):
class PluginTest10(BaseTest):

def test_plugin_authors(self):
pages = self.get_pages()
Expand Down Expand Up @@ -247,6 +247,8 @@ def test_plugin_authors(self):
casted_authors, __ = new[0].get_plugin_instance()
self.assertEqual(casted_authors.authors.count(), 3)

class PluginTest2(BaseTest):

def test_blog_category_plugin(self):
pages = self.get_pages()
posts = self.get_posts()
Expand Down

0 comments on commit c148331

Please sign in to comment.