Fix: Added and adjusted test_template
This commit is contained in:
parent
a224fcca2e
commit
18959d35df
2 changed files with 15 additions and 9 deletions
|
@ -155,16 +155,15 @@ Plugin Templates
|
|||
|
||||
Plugin templates live in the ``plugins`` folder of the folder specified by the **Template prefix**, or by default ``djangocms_blog``.
|
||||
|
||||
By defining the setting ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` you can allow multiple sets of plugin templates allowing for different views per plugin instance. You could, for example, have a plugin displaying latest posts as a list, a table or in masonry style.
|
||||
By defining the setting ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` you can allow multiple sets of plugin templates allowing for different views per plugin instance. You could, for example, have a plugin displaying latest posts as a list, a table or in masonry style.
|
||||
|
||||
To use this feature define ``BLOG_PLUGIN_TEMPLATE_FOLDERS`` as a list of available templates. Each item of this list itself is a list of the form ``('[folder_name]', '[verbose name]')``. Example:
|
||||
|
||||
BLOG_PLUGIN_TEMPLATE_FOLDERS = (
|
||||
('plugins', _('Default template') ), # reads from "templates/djangocms_blog/plugins/
|
||||
('timeline', _('Vertical timeline') ), # reads from "templates/djangocms_blog/vertical/
|
||||
('masonry', _('Masonry style') ), # reads from "templates/djangocms_blog/masonry/
|
||||
)
|
||||
|
||||
BLOG_PLUGIN_TEMPLATE_FOLDERS = (
|
||||
('plugins', _('Default template')), # reads from templates/djangocms_blog/plugins/
|
||||
('timeline', _('Vertical timeline')), # reads from templates/djangocms_blog/vertical/
|
||||
('masonry', _('Masonry style')), # reads from templates/djangocms_blog/masonry/
|
||||
)
|
||||
|
||||
Once defined, the plugin admin interface will allow content managers to select which template the plugin will use.
|
||||
|
||||
|
|
|
@ -189,11 +189,18 @@ class PluginTest(BaseTest):
|
|||
|
||||
context = self.get_plugin_context(pages[0], 'en', plugin)
|
||||
plugin_class = plugin.get_plugin_class_instance()
|
||||
self.assertEqual(plugin_class.get_render_template(context, plugin, ph), os.path.join('djangocms_blog', plugin_class.base_render_template))
|
||||
self.assertEqual(plugin_class.get_render_template(context, plugin, ph),
|
||||
os.path.join('djangocms_blog', plugin.template_folder, plugin_class.base_render_template))
|
||||
|
||||
self.app_config_1.app_data.config.template_prefix = 'whatever'
|
||||
self.app_config_1.save()
|
||||
self.assertEqual(plugin_class.get_render_template(context, plugin, ph), os.path.join('whatever', plugin_class.base_render_template))
|
||||
tmp = plugin.template_folder
|
||||
plugin.template_folder = 'whereever'
|
||||
plugin.save()
|
||||
self.assertEqual(plugin_class.get_render_template(context, plugin, ph),
|
||||
os.path.join('whatever', 'whereever', plugin_class.base_render_template))
|
||||
plugin.template_folder = tmp
|
||||
plugin.save()
|
||||
self.app_config_1.app_data.config.template_prefix = ''
|
||||
self.app_config_1.save()
|
||||
|
||||
|
|
Loading…
Reference in a new issue