From c0402575475e481d9d4dfdc64bf6f9e0cf90ad2b Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 25 Jul 2015 15:28:09 +0900 Subject: [PATCH] Slot: gen name retrun by __str__() when save() This name also used for itemize slots on admin screen Signed-off-by: Hiroshi Miura --- symposion/schedule/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/symposion/schedule/models.py b/symposion/schedule/models.py index 22aad378..487f2063 100644 --- a/symposion/schedule/models.py +++ b/symposion/schedule/models.py @@ -83,6 +83,7 @@ class SlotKind(models.Model): @python_2_unicode_compatible class Slot(models.Model): + name = models.CharField(max_length=100, editable=False) day = models.ForeignKey(Day, verbose_name=_("Day")) kind = models.ForeignKey(SlotKind, verbose_name=_("Kind")) start = models.TimeField(verbose_name=_("Start")) @@ -145,9 +146,13 @@ class Slot(models.Model): def rooms(self): return Room.objects.filter(pk__in=self.slotroom_set.values("room")) - def __str__(self): + def save(self, *args, **kwargs): roomlist = ' '.join(map(lambda r: r.__unicode__(), self.rooms)) - return "%s %s (%s - %s) %s" % (self.day, self.kind, self.start, self.end, roomlist) + self.name = "%s %s (%s - %s) %s" % (self.day, self.kind, self.start, self.end, roomlist) + super(Slot, self).save(*args, **kwargs) + + def __str__(self): + return self.name class Meta: ordering = ["day", "start", "end"]