Commits

mitar committed 5aa0cb7

Added text plugin template dir even if text plugin is not in INSTALLED_APPS as we are using its template.

Comments (0)

Files changed (1)

cmsplugin_markup/__init__.py

     Same as Above
     """
     pass
+
+# Add text plugin template dir even if it is not in INSTALLED_APPS
+try:
+    import os
+    import sys
+    from django.template.loaders import app_directories
+    from django.utils.importlib import import_module
+
+    fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
+
+    mod = import_module('cms.plugins.text')
+    template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
+
+    if os.path.isdir(template_dir):
+        try:
+            app_directories.app_template_dirs.index(template_dir)
+            # It is already there
+        except ValueError:
+            app_template_dirs = list(app_directories.app_template_dirs)
+            app_template_dirs.append(template_dir.decode(fs_encoding))
+            app_directories.app_template_dirs = tuple(app_template_dirs)
+except:
+    # Something went wrong, we will ignore it
+    pass