diff --git a/docs/features.rst b/docs/features.rst index 261c7a1..f7a3e4e 100644 --- a/docs/features.rst +++ b/docs/features.rst @@ -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. diff --git a/tests/test_plugins.py b/tests/test_plugins.py index e926fe4..7ef7202 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -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()