1. tehfink
  2. cmsplugin-faq


tehfink  committed 1ea203a

added a model method: `get_name()` instead of passing the name in the plugin context

  • Participants
  • Parent commits 313dcc5
  • Branches cms-2.X

Comments (0)

Files changed (2)

File cmsplugin_faq/cms_plugins.py

View file
         return super(CMSFaqEntryPlugin, self).get_form(request, obj, **kwargs)
     def render(self, context, instance, placeholder):
-        from django.template.defaultfilters import slugify
             'body': plugin_tags_to_user_html(instance.body, context, placeholder),
             'topic': instance.topic,
-            'name': slugify(instance.topic),
             'css': instance.get_css_display(),
             'placeholder': placeholder,
             'object': instance,

File cmsplugin_faq/models.py

View file
 from django.utils.text import truncate_words
 from cms.plugins.text.utils import plugin_admin_html_to_tags, plugin_tags_to_admin_html
 from django.conf import settings
+from django.template.defaultfilters import slugify
 #get custom css from settings or use default
     css = models.CharField(_('CSS class'), max_length=1, choices=CMSPLUGIN_FAQENTRY_CSS_CHOICES, blank=True, help_text=_('Additional CSS class to apply'))
     body = models.TextField(_("body"))
+    def get_name(self):
+        return slugify(self.topic)
     def _set_body_admin(self, text):
         self.body = plugin_admin_html_to_tags(text)