Commits

tehfink  committed b116643

added CMSFaqEntryLink; added options for CMSFaqEntry, CMSFaqList

  • Participants
  • Parent commits ee4a3ed

Comments (0)

Files changed (1)

File cmsplugin_faq/models.py

 from cms.plugins.text.utils import plugin_admin_html_to_tags, plugin_tags_to_admin_html
 from django.conf import settings
 
+
+#get custom css from settings or use default
+CMSPLUGIN_FAQENTRY_CSS_CHOICES = getattr(settings,"CMSPLUGIN_FAQENTRY_CSS_CHOICES", (('1', 'featured'),) )
+
 class FaqEntry(CMSPlugin):
     """Copy of Text plugin model, plus additional 'topic' Charfield"""
     topic = models.CharField(_("Topic"),max_length=500, help_text=_('FAQ entry topic'))
+    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 _set_body_admin(self, text):
                               """)
     
     def __unicode__(self):
-#        return u"%s" % (truncate_words(strip_tags(self.body), 3)[:30]+"...")
         return u"%s" % (truncate_words(self.topic, 5)[:30]+"...")
 
 
 #get custom css from settings or use default
-CMSPLUGIN_FAQLIST_CSS_CHOICES = getattr(settings,"CMSPLUGIN_FAQLIST_CSS_CHOICES", (('0', ''),('1', 'faq-list-entry'),('2', 'faq-list-entry-small'),) )
+CMSPLUGIN_FAQLIST_CSS_CHOICES = getattr(settings,"CMSPLUGIN_FAQLIST_CSS_CHOICES", (('1', 'faq-list'),('2', 'faq-list-small'),) )
 
 class FaqList(CMSPlugin):
     """Model to give FaqList plugin various options"""
-
-    css = models.CharField(_('CSS class'), max_length=1, choices=CMSPLUGIN_FAQLIST_CSS_CHOICES, default='0', help_text=_('Additional CSS class to apply'))
+    truncate_body = models.PositiveSmallIntegerField(_('Truncate words'), default=5, help_text=_('Truncate FAQ Entry body by this many words; zero means Django default'))
+    show_body = models.BooleanField(_('Show FAQ Entry body'),default=True)
+    css = models.CharField(_('CSS class'), max_length=1, choices=CMSPLUGIN_FAQLIST_CSS_CHOICES, blank=True, help_text=_('Additional CSS class to apply'))
 
     def __unicode__(self):
-        return u"%s" % (self.page.get_page_title())
+        return u"%s" % (self.page.get_page_title())
+
+#get custom css from settings or use default
+CMSPLUGIN_FAQENTRYLINK_CSS_CHOICES = getattr(settings,"CMSPLUGIN_FAQENTRYLINK_CSS_CHOICES", (('1', 'faq-entry-link-small'),) )
+
+class FaqEntryLink(CMSPlugin):
+    """Model to give FaqEntryLink plugin various options"""
+    link = models.ForeignKey(FaqEntry, blank=True, null=True, verbose_name=_('Linked FAQ Entry'), help_text=_('Leave empty for random'))
+    truncate_body = models.PositiveSmallIntegerField(_('Truncate words'), default=5, help_text=_('Truncate FAQ Entry body by this many words; zero means Django default'))
+    show_body = models.BooleanField(_('Show FAQ Entry body'),default=True)
+    css = models.CharField(_('CSS class'), max_length=1, choices=CMSPLUGIN_FAQENTRYLINK_CSS_CHOICES, blank=True, help_text=_('Additional CSS class to apply'))
+
+    def __unicode__(self):
+        return u"FAQ Entry %s" % (self.link)