1 from django.db import models
2 from django.utils.translation import ugettext_lazy as _
5 class Sponsor(models.Model):
6 name = models.CharField(_('name'), max_length=120)
7 _description = models.CharField(_('description'), blank=True, max_length=255)
8 logo = models.ImageField(_('logo'), upload_to='sponsors/sponsor/logo')
9 url = models.URLField(_('url'), blank=True, verify_exists=False)
11 def __unicode__(self):
14 def description(self):
15 if len(self._description):
16 return self._description
21 class SponsorGroup(models.Model):
22 name = models.CharField(_('name'), max_length=120)
23 order = models.IntegerField(_('order'), default=0)
24 column_width = models.PositiveIntegerField(_('column width'))
25 sponsor_ids = models.CommaSeparatedIntegerField(_('sponsors'), max_length=255)
28 ids = [int(pk) for pk in self.sponsor_ids.split(',')]
29 result = Sponsor.objects.in_bulk(ids)
30 return [result[pk] for pk in ids]
31 sponsors.changes_data = False
33 def __unicode__(self):