1 from django.conf import settings
2 from django.db import models
3 from django.utils.translation import ugettext_lazy as _
4 from ssify import flush_ssi_includes
7 class Chunk(models.Model):
9 A Chunk is a piece of content associated with a unique key that can be inserted into
10 any template with the use of a special template tag.
12 key = models.CharField(_('key'), help_text=_('A unique name for this chunk of content'), primary_key=True, max_length=255)
13 description = models.CharField(_('description'), blank=True, max_length=255)
14 content = models.TextField(_('content'), blank=True)
18 verbose_name = _('chunk')
19 verbose_name_plural = _('chunks')
21 def __unicode__(self):
24 def save(self, *args, **kwargs):
25 ret = super(Chunk, self).save(*args, **kwargs)
29 def flush_includes(self):
31 '/chunks/chunk/%s.%s.html' % (self.key, lang)
32 for lang in [lc for (lc, _ln) in settings.LANGUAGES]])
36 class Attachment(models.Model):
37 key = models.CharField(_('key'), help_text=_('A unique name for this attachment'), primary_key=True, max_length=255)
38 attachment = models.FileField(upload_to='chunks/attachment')
42 verbose_name, verbose_name_plural = _('attachment'), _('attachments')
44 def __unicode__(self):