Merge pull request #171 from peacedata/plugin_names_settings

Add blog plugin module/names settings
This commit is contained in:
Iacopo Spalletti 2015-11-28 09:09:28 +01:00
commit e54be8e8b8
3 changed files with 30 additions and 12 deletions

View file

@ -369,6 +369,12 @@ Global Settings
* BLOG_CURRENT_POST_IDENTIFIER: Current post identifier in request (default ``djangocms_post_current``) * BLOG_CURRENT_POST_IDENTIFIER: Current post identifier in request (default ``djangocms_post_current``)
* BLOG_CURRENT_NAMESPACE: Current post config identifier in request (default: ``djangocms_post_current_config``) * BLOG_CURRENT_NAMESPACE: Current post config identifier in request (default: ``djangocms_post_current_config``)
* BLOG_ENABLE_THROUGH_TOOLBAR_MENU: Is the toolbar menu throught whole all applications (default: ``False``) * BLOG_ENABLE_THROUGH_TOOLBAR_MENU: Is the toolbar menu throught whole all applications (default: ``False``)
* BLOG_PLUGIN_MODULE_NAME: Blog plugin module name (default: ``Blog``)
* BLOG_LATEST_ENTRIES_PLUGIN_NAME: Blog latest entries plugin name (default: ``Latest Blog Articles``)
* BLOG_AUTHOR_POSTS_PLUGIN_NAME: Blog author posts plugin name (default: ``Author Blog Articles``)
* BLOG_TAGS_PLUGIN_NAME: Blog tags plugin name (default: ``Tags``)
* BLOG_CATEGORY_PLUGIN_NAME: Blog categories plugin name (default: ``Categories``)
* BLOG_ARCHIVE_PLUGIN_NAME: Blog archive plugin name (default: ``Archive``)
Read-only settings Read-only settings
++++++++++++++++++ ++++++++++++++++++

View file

@ -5,7 +5,6 @@ import os.path
from cms.plugin_base import CMSPluginBase from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext_lazy as _
from .forms import LatestEntriesForm from .forms import LatestEntriesForm
from .models import AuthorEntriesPlugin, BlogCategory, GenericBlogPlugin, LatestPostsPlugin, Post from .models import AuthorEntriesPlugin, BlogCategory, GenericBlogPlugin, LatestPostsPlugin, Post
@ -13,7 +12,7 @@ from .settings import get_setting
class BlogPlugin(CMSPluginBase): class BlogPlugin(CMSPluginBase):
module = 'Blog' module = get_setting('PLUGIN_MODULE_NAME')
def get_render_template(self, context, instance, placeholder): def get_render_template(self, context, instance, placeholder):
if instance.app_config and instance.app_config.template_prefix: if instance.app_config and instance.app_config.template_prefix:
@ -27,7 +26,7 @@ class BlogLatestEntriesPlugin(BlogPlugin):
Non cached plugin which returns the latest posts taking into account the Non cached plugin which returns the latest posts taking into account the
user / toolbar state user / toolbar state
""" """
name = _('Latest Blog Articles') name = get_setting('LATEST_ENTRIES_PLUGIN_NAME')
model = LatestPostsPlugin model = LatestPostsPlugin
form = LatestEntriesForm form = LatestEntriesForm
filter_horizontal = ('categories',) filter_horizontal = ('categories',)
@ -46,7 +45,7 @@ class BlogLatestEntriesPluginCached(BlogPlugin):
""" """
Cached plugin which returns the latest published posts Cached plugin which returns the latest published posts
""" """
name = _('Latest Blog Articles') name = get_setting('LATEST_ENTRIES_PLUGIN_NAME')
model = LatestPostsPlugin model = LatestPostsPlugin
form = LatestEntriesForm form = LatestEntriesForm
filter_horizontal = ('categories',) filter_horizontal = ('categories',)
@ -61,8 +60,8 @@ class BlogLatestEntriesPluginCached(BlogPlugin):
class BlogAuthorPostsPlugin(BlogPlugin): class BlogAuthorPostsPlugin(BlogPlugin):
module = _('Blog') module = get_setting('PLUGIN_MODULE_NAME')
name = _('Author Blog Articles') name = get_setting('AUTHOR_POSTS_PLUGIN_NAME')
model = AuthorEntriesPlugin model = AuthorEntriesPlugin
base_render_template = 'plugins/authors.html' base_render_template = 'plugins/authors.html'
filter_horizontal = ['authors'] filter_horizontal = ['authors']
@ -74,8 +73,8 @@ class BlogAuthorPostsPlugin(BlogPlugin):
class BlogTagsPlugin(BlogPlugin): class BlogTagsPlugin(BlogPlugin):
module = _('Blog') module = get_setting('PLUGIN_MODULE_NAME')
name = _('Tags') name = get_setting('TAGS_PLUGIN_NAME')
model = GenericBlogPlugin model = GenericBlogPlugin
base_render_template = 'plugins/tags.html' base_render_template = 'plugins/tags.html'
@ -90,8 +89,8 @@ class BlogTagsPlugin(BlogPlugin):
class BlogCategoryPlugin(BlogPlugin): class BlogCategoryPlugin(BlogPlugin):
module = _('Blog') module = get_setting('PLUGIN_MODULE_NAME')
name = _('Categories') name = get_setting('CATEGORY_PLUGIN_NAME')
model = GenericBlogPlugin model = GenericBlogPlugin
base_render_template = 'plugins/categories.html' base_render_template = 'plugins/categories.html'
@ -105,8 +104,8 @@ class BlogCategoryPlugin(BlogPlugin):
class BlogArchivePlugin(BlogPlugin): class BlogArchivePlugin(BlogPlugin):
module = _('Blog') module = get_setting('PLUGIN_MODULE_NAME')
name = _('Archive') name = get_setting('ARCHIVE_PLUGIN_NAME')
model = GenericBlogPlugin model = GenericBlogPlugin
base_render_template = 'plugins/archive.html' base_render_template = 'plugins/archive.html'

View file

@ -107,5 +107,18 @@ def get_setting(name):
settings, 'BLOG_CURRENT_NAMESPACE', 'djangocms_post_current_config'), settings, 'BLOG_CURRENT_NAMESPACE', 'djangocms_post_current_config'),
'BLOG_ENABLE_THROUGH_TOOLBAR_MENU': getattr( 'BLOG_ENABLE_THROUGH_TOOLBAR_MENU': getattr(
settings, 'BLOG_ENABLE_THROUGH_TOOLBAR_MENU', False), settings, 'BLOG_ENABLE_THROUGH_TOOLBAR_MENU', False),
'BLOG_PLUGIN_MODULE_NAME': getattr(settings, 'BLOG_PLUGIN_MODULE_NAME', _('Blog')),
'BLOG_LATEST_ENTRIES_PLUGIN_NAME': getattr(
settings, 'BLOG_LATEST_ENTRIES_PLUGIN_NAME', _('Latest Blog Articles')),
'BLOG_AUTHOR_POSTS_PLUGIN_NAME': getattr(
settings, 'BLOG_AUTHOR_POSTS_PLUGIN_NAME', _('Author Blog Articles')),
'BLOG_TAGS_PLUGIN_NAME': getattr(
settings, 'BLOG_TAGS_PLUGIN_NAME', _('Tags')),
'BLOG_CATEGORY_PLUGIN_NAME': getattr(
settings, 'BLOG_CATEGORY_PLUGIN_NAME', _('Categories')),
'BLOG_ARCHIVE_PLUGIN_NAME': getattr(
settings, 'BLOG_ARCHIVE_PLUGIN_NAME', _('Archive')),
} }
return default['BLOG_%s' % name] return default['BLOG_%s' % name]