From f32b51cdc9dc120a41a120e335a343493d24c47f Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 21 Mar 2011 15:42:52 +0100 Subject: modified Note: added redundant fields for better admin, limited choices to time slots in the future. diff --git a/program/models.py b/program/models.py index 37cf904..3864381 100644 --- a/program/models.py +++ b/program/models.py @@ -242,12 +242,15 @@ class Note(models.Model): (1, _("Recommendation")), (2, _("Repetition")), ) - timeslot = models.OneToOneField(TimeSlot, verbose_name=_("Time slot")) + timeslot = models.OneToOneField(TimeSlot, limit_choices_to={'start__gte': datetime.now}, verbose_name=_("Time slot")) owner = models.ForeignKey(User, related_name='notes', verbose_name=_("Owner")) title = models.CharField(_("Title"), max_length=128) content = models.TextField(_("Content")) status = models.IntegerField(_("Status"), choices=STATUS_CHOICES, default=1) cba_entry_id = models.IntegerField(_("CBA entry ID"), blank=True, null=True) + start = models.DateTimeField(editable=False) + end = models.DateTimeField(editable=False) + show = models.ForeignKey(Show, editable=False) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) @@ -259,5 +262,9 @@ class Note(models.Model): def __unicode__(self): return u'%s - %s' % (self.title, self.timeslot) - def show(self): - return self.timeslot.programslot.show + def save(self, *args, **kwargs): + super(Note, self).save(*args, **kwargs) + + self.start = self.timeslot.start + self.end = self.timeslot.end + self.show = self.timeslot.programslot.show -- cgit v0.10.2