diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-21 19:47:19 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-21 19:47:19 +0100 |
commit | 891b3abb44f1a4a855510be70b2048ed955bbe17 (patch) | |
tree | 51d2636ed80d9120cd3be541e2b7f01592f42694 /feincms/content/image/models.py | |
parent | 01b0980c441a7a2a9e47680ee0b025e648c9ef0f (diff) | |
download | troggle-891b3abb44f1a4a855510be70b2048ed955bbe17.tar.gz troggle-891b3abb44f1a4a855510be70b2048ed955bbe17.tar.bz2 troggle-891b3abb44f1a4a855510be70b2048ed955bbe17.zip |
[svn] Updates to allow subcave tree with nice admin.
Diffstat (limited to 'feincms/content/image/models.py')
-rw-r--r-- | feincms/content/image/models.py | 32 |
1 files changed, 32 insertions, 0 deletions
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') + |