diff --git a/program/models.py b/program/models.py index 51199a17790ff480ef4bcd26aff951196b446d3c..acd065cce7d14122d6e802bf31467327b3c18440 100644 --- a/program/models.py +++ b/program/models.py @@ -372,8 +372,7 @@ class Schedule(models.Model): if ends[k].date() > schedule.until: schedule.until = ends[k].date() - timeslots.append( - TimeSlot(schedule=schedule, start=timezone.make_aware(starts[k]), end=timezone.make_aware(ends[k])).generate()) + timeslots.append(TimeSlot(schedule=schedule, start=timezone.make_aware(starts[k]), end=timezone.make_aware(ends[k]))) return timeslots @@ -832,7 +831,7 @@ class TimeSlotManager(models.Manager): def instantiate(start, end, schedule, show): return TimeSlot(start=parse_datetime(start), end=parse_datetime(end), - show=show, is_repetition=schedule.is_repetition, schedule=schedule).generate() + show=show, is_repetition=schedule.is_repetition, schedule=schedule) @staticmethod def get_24h_timeslots(start): @@ -875,17 +874,10 @@ class TimeSlot(models.Model): super(TimeSlot, self).save(*args, **kwargs) return self - # FIXME: this should be a property - def generate(self): - """Returns the object instance without saving""" - - self.show = self.schedule.show - - # Generate a distinct and reproducible hash for the timeslot - # Makes sure none of these fields changed when updating a schedule + @property + def hash(self): string = str(self.start) + str(self.end) + str(self.schedule.rrule.id) + str(self.schedule.byweekday) - self.hash = str(''.join(s for s in string if s.isdigit())) - return self + return str(''.join(s for s in string if s.isdigit())) class Note(models.Model):