diff --git a/packages/blog/admin.py b/packages/blog/admin.py index cb7023d..fec2162 100755 --- a/packages/blog/admin.py +++ b/packages/blog/admin.py @@ -21,16 +21,16 @@ class BlogCategoryAdmin(EnhancedModelAdminMixin, TranslatableAdmin): class Media: css = { - 'all': ('%sblog/css/%s' % (settings.STATIC_URL, - 'blog_admin.css'),) + 'all': ('%sblog/css/%s' % (settings.STATIC_URL, 'djangocms_blog_admin'),) } class PostAdmin(EnhancedModelAdminMixin, FrontendEditableAdminMixin, PlaceholderAdminMixin, TranslatableAdmin, admin.ModelAdmin): form = PostAdminForm - list_display = ['title', 'author', 'date_published', 'date_published_end'] + list_display = ['title', 'author', 'date_published'] date_hierarchy = 'date_published' + list_filter = ('categories', 'author') raw_id_fields = ['author'] frontend_editable_fields = ('title', 'abstract', 'post_text') enhance_exclude = ('main_image', 'tags') @@ -75,12 +75,6 @@ class PostAdmin(EnhancedModelAdminMixin, FrontendEditableAdminMixin, obj.author = user super(PostAdmin, self).save_model(request, obj, form, change) - class Media: - css = { - 'all': ('%sblog/css/%s' % (settings.STATIC_URL, - 'blog_admin.css'),) - } - class BlogConfigAdmin( PlaceholderAdminMixin, @@ -90,7 +84,7 @@ class BlogConfigAdmin( def get_config_fields(self): return ( 'app_title', 'category_slug', - 'paginate_by' ) + 'paginate_by') admin.site.register(BlogConfig, BlogConfigAdmin) diff --git a/packages/blog/cms_plugins.py b/packages/blog/cms_plugins.py index d5502b4..c436459 100644 --- a/packages/blog/cms_plugins.py +++ b/packages/blog/cms_plugins.py @@ -19,6 +19,7 @@ class BlogLatestEntriesPlugin(BlogPlugin): Non cached plugin which returns the latest posts taking into account the user / toolbar state """ + fields = ['app_config', 'latest_posts', 'tags', 'categories'] render_template = 'blog/plugins/latest_entries.html' name = _('Latest Blog Articles') model = LatestPostsPlugin diff --git a/packages/blog/models.py b/packages/blog/models.py index c63c1d0..cdb62b0 100644 --- a/packages/blog/models.py +++ b/packages/blog/models.py @@ -266,13 +266,19 @@ class LatestPostsPlugin(BasePostPlugin): categories = models.ManyToManyField('BlogCategory', blank=True, help_text=_('Show only the blog articles tagged with chosen categories.')) + tags = TaggableManager(_('filter by tag'), blank=True, + help_text=_('Show only the blog articles tagged with chosen tags.'), + related_name='djangocms_blog_latest_post') + def __str__(self): return u'%s latest articles by category' % self.latest_posts - def get_posts(self, request): posts = self.post_queryset(request) + if self.tags.exists(): + posts = posts.filter(tags__in=list(self.tags.all())) + if self.categories.exists(): posts = posts.filter(categories__in=list(self.categories.all()))