Skip to content

Instantly share code, notes, and snippets.

@pifantastic
Created August 20, 2011 18:44
Show Gist options
  • Save pifantastic/1159479 to your computer and use it in GitHub Desktop.
Save pifantastic/1159479 to your computer and use it in GitHub Desktop.
class Appointment(models.Model):
# ... #
def save(self, *args, **kwargs):
update_series = kwargs.pop('update_series', True)
super(Appointment, self).save(*args, **kwargs)
if update_series and self.rrule:
rrule = self.rrule.get_rrule()
for date in rrule.between(self.start_time, self.start_time + timedelta(days=365 * 2)):
appt = Appointment()
appt.start_time = date
appt.rrule = self.rrule
appt.save(update_series=False)
appt.services = self.services.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment