Created
October 5, 2009 00:39
-
-
Save tehfink/201725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cms.plugin_pool import plugin_pool | |
from django.utils.translation import ugettext as _ | |
from models import FaqEntry | |
from cms.plugins.text.cms_plugins import TextPlugin | |
class CMSFaqPlugin(TextPlugin): | |
"""Overrides cms TextPlugin class, adds values for FAQ entry""" | |
model = FaqEntry | |
name = _("FAQ Entry") | |
render_template = "plugins/faq_entry.html" | |
def render(self, context, instance, placeholder): | |
context.update({ | |
'body':plugin_tags_to_user_html(instance.body, context, placeholder), | |
'topic':instance.topic, | |
'placeholder':placeholder, | |
'object':instance | |
}) | |
return context | |
plugin_pool.register_plugin(CMSFaqPlugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
from cms.plugins.text.models import Text | |
class FaqEntry(Text): | |
"""Overrides cms Text plugin model, adds values for FAQ entry""" | |
topic = models.CharField(_("FAQ entry topic"),max_length=500) | |
#overrides Text's values | |
search_fields = ('body','topic',) | |
#overrides Text's values | |
def __unicode__(self): | |
return u"%s" % (truncate_words(strip_tags(self.topic), 3)[:30]+"...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div>{{ topic }}</div> | |
<div> | |
{{ body|safe }} | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment