From 54a62999c03f5293b42d56f9a99b1c5a3b02fa5f Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Thu, 21 May 2009 19:47:19 +0100 Subject: [svn] Updates to allow subcave tree with nice admin. --- feincms/content/image/models.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 feincms/content/image/models.py (limited to 'feincms/content/image/models.py') diff --git a/feincms/content/image/models.py b/feincms/content/image/models.py new file mode 100644 index 0000000..2f1d2c4 --- /dev/null +++ b/feincms/content/image/models.py @@ -0,0 +1,32 @@ +from django.db import models +from django.template.loader import render_to_string +from django.utils.translation import ugettext_lazy as _ + +class ImageContent(models.Model): + """ + Create an ImageContent like this: + + Cls.create_content_type(ImageContent, POSITION_CHOICES=( + ('left', 'Left'), + ('right', Right'), + )) + """ + + image = models.ImageField(_('image'), upload_to='imagecontent') + + class Meta: + abstract = True + verbose_name = _('image') + verbose_name_plural = _('images') + + def render(self, **kwargs): + return render_to_string([ + 'content/image/%s.html' % self.position, + 'content/image/default.html', + ], {'content': self}) + + @classmethod + def handle_kwargs(cls, POSITION_CHOICES=()): + models.CharField(_('position'), max_length=10, choices=POSITION_CHOICES + ).contribute_to_class(cls, 'position') + -- cgit v1.2.3