Generated: Wed 2013-03-13 10:33 CET
Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/cms/plugins/snippet/models.py
Stats: 0 executed, 14 missed, 8 excluded, 21 ignored
from django.db import modelsfrom django.utils.translation import ugettext_lazy as _from cms.models import CMSPluginfrom cms.utils.helpers import reversion_register# Stores the actual dataclass Snippet(models.Model): """ A snippet of HTML or a Django template """ name = models.CharField(_("name"), max_length=255, unique=True) html = models.TextField(_("HTML"), blank=True) template = models.CharField(_("template"), max_length=50, blank=True, \ help_text=_('Enter a template (i.e. "snippets/plugin_xy.html") which will be rendered. ' + \ 'If "template" is given, the contents of field "HTML" will be passed as template variable {{ html }} to the template. ' + \ 'Else, the content of "HTML" is rendered.')) def __unicode__(self): return self.name class Meta: ordering = ['name'] verbose_name = _("Snippet") verbose_name_plural = _("Snippets")# Plugin model - just a pointer to Snippetclass SnippetPtr(CMSPlugin): snippet = models.ForeignKey(Snippet) class Meta: verbose_name = _("Snippet") search_fields = ('snippet__html',) def __unicode__(self): # Return the referenced snippet's name rather than the default (ID #) return self.snippet.name# We don't both with SnippetPtr, since all the data is actually in Snippetreversion_register(Snippet)