From e5b3de7ef4b068d1ce01e8fc9aec59b9182d8662 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 26 Feb 2016 23:48:37 +0100 Subject: [PATCH 1/4] fix error in wizard tests --- tests/test_wizards.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_wizards.py b/tests/test_wizards.py index 56fe2a2..b3da377 100644 --- a/tests/test_wizards.py +++ b/tests/test_wizards.py @@ -67,7 +67,7 @@ class WizardTest(BaseTest): }, prefix=1) self.assertEqual(form.default_appconfig, app_config) self.assertTrue(form.is_valid()) - self.assertTrue(form.cleaned_data['app_config'], app_config) + self.assertEqual(form.cleaned_data['app_config'].pk, app_config) instance = form.save() self.assertEqual(instance.author, self.user_staff) @@ -81,7 +81,7 @@ class WizardTest(BaseTest): }, prefix=1) self.assertEqual(form.default_appconfig, app_config) self.assertTrue(form.is_valid()) - self.assertTrue(form.cleaned_data['app_config'], app_config) + self.assertEqual(form.cleaned_data['app_config'].pk, app_config) instance = form.save() self.assertEqual(instance.author, self.user_normal) From 90ed83c821a8010310f3d92d6a53d6a30818fccb Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 26 Feb 2016 23:48:48 +0100 Subject: [PATCH 2/4] Test copy relations --- tests/test_plugins.py | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index cb209f2..8a241d9 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -59,6 +59,24 @@ class PluginTest(BaseTest): self.assertTrue(rendered.find('
-1) self.assertTrue(rendered.find(posts[1].get_absolute_url()) > -1) + # Checking copy relations + ph = pages[0].placeholders.get(slot='content') + original = ph.get_plugins('en') + pages[0].publish('en') + published = pages[0].get_public_object() + ph = published.placeholders.get(slot='content') + new = ph.get_plugins('en') + self.assertNotEqual(original, new) + + casted_tags, __ = new[0].get_plugin_instance() + casted_categories, __ = new[1].get_plugin_instance() + + self.assertEqual(casted_tags.tags.count(), 1) + self.assertEqual(casted_tags.categories.count(), 0) + + self.assertEqual(casted_categories.tags.count(), 0) + self.assertEqual(casted_categories.categories.count(), 1) + def test_plugin_authors(self): pages = self.get_pages() posts = self.get_posts() @@ -73,6 +91,36 @@ class PluginTest(BaseTest): rendered = plugin.render_plugin(context, ph) self.assertTrue(rendered.find('No article found') > -1) + plugin.authors.add(self.user) + context = self.get_plugin_context(pages[0], 'en', plugin, edit=True) + rendered = plugin.render_plugin(context, ph) + self.assertTrue(rendered.find('/en/blog/author/admin/') > -1) + self.assertTrue(rendered.find('2 articles') > -1) + + plugin.authors.add(self.user_staff) + context = self.get_plugin_context(pages[0], 'en', plugin, edit=True) + rendered = plugin.render_plugin(context, ph) + self.assertTrue(rendered.find('/en/blog/author/staff/') > -1) + self.assertTrue(rendered.find('0 articles') > -1) + + plugin.authors.add(self.user_normal) + context = self.get_plugin_context(pages[0], 'en', plugin, edit=True) + rendered = plugin.render_plugin(context, ph) + self.assertTrue(rendered.find('/en/blog/author/normal/') > -1) + self.assertTrue(rendered.find('0 articles') > -1) + + # Checking copy relations + ph = pages[0].placeholders.get(slot='content') + original = ph.get_plugins('en') + pages[0].publish('en') + published = pages[0].get_public_object() + ph = published.placeholders.get(slot='content') + new = ph.get_plugins('en') + self.assertNotEqual(original, new) + + casted_authors, __ = new[0].get_plugin_instance() + self.assertEqual(casted_authors.authors.count(), 3) + def test_plugin_tags(self): pages = self.get_pages() posts = self.get_posts() From d11bb96bd41131e9d11b953fabac9af2309e9be9 Mon Sep 17 00:00:00 2001 From: German Ilyin Date: Sat, 27 Feb 2016 03:30:31 +0600 Subject: [PATCH 3/4] Fixing #209 --- djangocms_blog/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 8de9272..564c570 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -324,6 +324,8 @@ class LatestPostsPlugin(BasePostPlugin): def copy_relations(self, oldinstance): for tag in oldinstance.tags.all(): self.tags.add(tag) + for category in oldinstance.categories.all(): + self.categories.add(category) def get_posts(self, request): posts = self.post_queryset(request) From b1ac45399e4bbd42a6222e16e39cc03368b55de0 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 26 Feb 2016 23:50:15 +0100 Subject: [PATCH 4/4] Update history --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index a2d231d..61780a4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,7 @@ History * Fix some issues with haystack indexes * Add support for moved ThumbnailOption * Fix Django 1.9 issues +* Fix copy relations method in plugins 0.6.3 (2015-12-22) ++++++++++++++++++