From 58e6157dbbd2d84ce2902a115e9dce1a4f81128a Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 16 Nov 2015 21:48:55 +0100 Subject: [PATCH] Fix __str__ method --- djangocms_blog/cms_plugins.py | 4 ++-- djangocms_blog/models.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/djangocms_blog/cms_plugins.py b/djangocms_blog/cms_plugins.py index 26bf300..ec60f01 100644 --- a/djangocms_blog/cms_plugins.py +++ b/djangocms_blog/cms_plugins.py @@ -31,7 +31,7 @@ class BlogLatestEntriesPlugin(BlogPlugin): model = LatestPostsPlugin form = LatestEntriesForm filter_horizontal = ('categories',) - fields = ('latest_posts', 'tags', 'categories') + fields = ('app_config', 'latest_posts', 'tags', 'categories') cache = False base_render_template = 'plugins/latest_entries.html' @@ -50,7 +50,7 @@ class BlogLatestEntriesPluginCached(BlogPlugin): model = LatestPostsPlugin form = LatestEntriesForm filter_horizontal = ('categories',) - fields = ('latest_posts', 'tags', 'categories') + fields = ('app_config', 'latest_posts', 'tags', 'categories') base_render_template = 'plugins/latest_entries.html' def render(self, context, instance, placeholder): diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 9ea7fc0..3e94215 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -270,7 +270,6 @@ class Post(ModelMeta, TranslatableModel): return self.make_full_url(self.get_absolute_url()) -@python_2_unicode_compatible class BasePostPlugin(CMSPlugin): app_config = AppHookConfigField( BlogConfig, null=True, verbose_name=_('app. config'), blank=True @@ -287,12 +286,10 @@ class BasePostPlugin(CMSPlugin): posts = posts.active_translations(language_code=language) if not request or not getattr(request, 'toolbar', False) or not request.toolbar.edit_mode: posts = posts.published() - return posts - - def __str__(self): - return _('generic blog plugin') + return posts.all() +@python_2_unicode_compatible class LatestPostsPlugin(BasePostPlugin): latest_posts = models.IntegerField(_('articles'), default=get_setting('LATEST_POSTS'), help_text=_('The number of latests ' @@ -306,7 +303,7 @@ class LatestPostsPlugin(BasePostPlugin): u'with chosen categories.')) def __str__(self): - return _('%s latest articles by tag') % self.latest_posts + return force_text(_('%s latest articles by tag') % self.latest_posts) def copy_relations(self, oldinstance): for tag in oldinstance.tags.all(): @@ -321,6 +318,7 @@ class LatestPostsPlugin(BasePostPlugin): return posts.distinct()[:self.latest_posts] +@python_2_unicode_compatible class AuthorEntriesPlugin(BasePostPlugin): authors = models.ManyToManyField( dj_settings.AUTH_USER_MODEL, verbose_name=_('authors'), @@ -332,7 +330,7 @@ class AuthorEntriesPlugin(BasePostPlugin): ) def __str__(self): - return _('%s latest articles by author') % self.latest_posts + return force_text(_('%s latest articles by author') % self.latest_posts) def copy_relations(self, oldinstance): self.authors = oldinstance.authors.all() @@ -354,7 +352,11 @@ class AuthorEntriesPlugin(BasePostPlugin): return authors +@python_2_unicode_compatible class GenericBlogPlugin(BasePostPlugin): class Meta: abstract = False + + def __str__(self): + return force_text(_('generic blog plugin'))