Skip to content
Browse files

Bug fix: Modifying event duplicates persisted occurrences

  • Loading branch information...
1 parent 53167d7 commit c17cb673bf8116b533346f313070f5684faace3c @keiouu keiouu committed Sep 13, 2011
Showing with 13 additions and 1 deletion.
  1. +13 −1 schedule/models/events.py
View
14 schedule/models/events.py
@@ -48,6 +48,18 @@ def __unicode__(self):
'end': date(self.end, date_format),
}
+ def save(self, *args, **kwargs):
+ if self.pk:
+ old_event = Event.objects.get(pk=self.pk)
+ occurences = Occurrence.objects.filter(event=self.pk)
+ for occ in occurences:
+ occ.original_start = occ.original_start + (self.start - old_event.start)
+ print occ.original_start
+ occ.original_end = occ.original_end + (self.end - old_event.end)
+ occ.save()
+
+ super(Event, self).save(*args, **kwargs)
+
def get_absolute_url(self):
return reverse('event', args=[self.id])
@@ -132,7 +144,7 @@ def _get_occurrence_list(self, start, end):
o_starts = rule.between(start-difference, end, inc=False)
for o_start in o_starts:
o_end = o_start + difference
- occurrences.append(self._create_occurrence(o_start, o_end))
+ occurrences.append(self.get_occurrence(o_start))
return occurrences
else:
# check if event is in the period

0 comments on commit c17cb67

Please sign in to comment.
Something went wrong with that request. Please try again.