Add blog plugin module/names settings

This commit is contained in:
Georgiy Kutsurua 2015-11-28 02:26:04 +04:00
parent e68d9d1083
commit 5819a0f019
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_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_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
++++++++++++++++++

View file

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

View file

@ -107,5 +107,18 @@ def get_setting(name):
settings, 'BLOG_CURRENT_NAMESPACE', 'djangocms_post_current_config'),
'BLOG_ENABLE_THROUGH_TOOLBAR_MENU': getattr(
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]