From dad1569aeabcc92ad6407cf05d13f989ff18257c Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Wed, 6 Jul 2016 15:40:45 +0200 Subject: [PATCH] Added: Hide admin interface if only one template is available Added: Migrations --- djangocms_blog/cms_plugins.py | 10 +++++-- .../migrations/0024_auto_20160706_1524.py | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 djangocms_blog/migrations/0024_auto_20160706_1524.py diff --git a/djangocms_blog/cms_plugins.py b/djangocms_blog/cms_plugins.py index 91dac35..77cce05 100644 --- a/djangocms_blog/cms_plugins.py +++ b/djangocms_blog/cms_plugins.py @@ -36,7 +36,8 @@ class BlogLatestEntriesPlugin(BlogPlugin): model = LatestPostsPlugin form = LatestEntriesForm filter_horizontal = ('categories',) - fields = ('app_config', 'latest_posts', 'tags', 'categories') + fields = ['app_config', 'latest_posts', 'tags', 'categories'] + \ + ['template_folder'] if len(get_setting('PLUGIN_TEMPLATE_FOLDERS'))>1 else [] cache = False base_render_template = 'latest_entries.html' @@ -55,7 +56,8 @@ class BlogLatestEntriesPluginCached(BlogPlugin): model = LatestPostsPlugin form = LatestEntriesForm filter_horizontal = ('categories',) - fields = ('app_config', 'latest_posts', 'tags', 'categories') + fields = ['app_config', 'latest_posts', 'tags', 'categories']+ \ + ['template_folder'] if len(get_setting('PLUGIN_TEMPLATE_FOLDERS'))>1 else [] base_render_template = 'latest_entries.html' def render(self, context, instance, placeholder): @@ -71,6 +73,7 @@ class BlogAuthorPostsPlugin(BlogPlugin): model = AuthorEntriesPlugin base_render_template = 'authors.html' filter_horizontal = ['authors'] + exclude = ['template_folder'] if len(get_setting('PLUGIN_TEMPLATE_FOLDERS'))>=1 else [] def render(self, context, instance, placeholder): context = super(BlogAuthorPostsPlugin, self).render(context, instance, placeholder) @@ -83,6 +86,7 @@ class BlogTagsPlugin(BlogPlugin): name = get_setting('TAGS_PLUGIN_NAME') model = GenericBlogPlugin base_render_template = 'tags.html' + exclude = ['template_folder'] if len(get_setting('PLUGIN_TEMPLATE_FOLDERS'))>=1 else [] def render(self, context, instance, placeholder): context = super(BlogTagsPlugin, self).render(context, instance, placeholder) @@ -96,6 +100,7 @@ class BlogCategoryPlugin(BlogPlugin): name = get_setting('CATEGORY_PLUGIN_NAME') model = GenericBlogPlugin base_render_template = 'categories.html' + exclude = ['template_folder'] if len(get_setting('PLUGIN_TEMPLATE_FOLDERS'))>=1 else [] def render(self, context, instance, placeholder): context = super(BlogCategoryPlugin, self).render(context, instance, placeholder) @@ -116,6 +121,7 @@ class BlogArchivePlugin(BlogPlugin): name = get_setting('ARCHIVE_PLUGIN_NAME') model = GenericBlogPlugin base_render_template = 'archive.html' + exclude = ['template_folder'] if len(get_setting('PLUGIN_TEMPLATE_FOLDERS'))>=1 else [] def render(self, context, instance, placeholder): context = super(BlogArchivePlugin, self).render(context, instance, placeholder) diff --git a/djangocms_blog/migrations/0024_auto_20160706_1524.py b/djangocms_blog/migrations/0024_auto_20160706_1524.py new file mode 100644 index 0000000..f5eaf57 --- /dev/null +++ b/djangocms_blog/migrations/0024_auto_20160706_1524.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('djangocms_blog', '0023_auto_20160626_1539'), + ] + + operations = [ + migrations.AddField( + model_name='authorentriesplugin', + name='template_folder', + field=models.CharField(default='Default template', verbose_name='Plugin template', max_length=40, help_text='Select plugin template to load for this instance', choices=[('plugins', 'Default template')]), + ), + migrations.AddField( + model_name='genericblogplugin', + name='template_folder', + field=models.CharField(default='Default template', verbose_name='Plugin template', max_length=40, help_text='Select plugin template to load for this instance', choices=[('plugins', 'Default template')]), + ), + migrations.AddField( + model_name='latestpostsplugin', + name='template_folder', + field=models.CharField(default='Default template', verbose_name='Plugin template', max_length=40, help_text='Select plugin template to load for this instance', choices=[('plugins', 'Default template')]), + ), + ]