From: Seth Woodworth Date: Mon, 25 Mar 2013 16:41:09 +0000 (-0400) Subject: on Note.save, if upload date is greater than course.updated_at time, update course... X-Git-Tag: release-20150131~472 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fe06e82747734cef58655f112d89042b3d39b320;p=oweals%2Fkarmaworld.git on Note.save, if upload date is greater than course.updated_at time, update course datetime, fixes #83 --- diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index 5b34fdc..877997d 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -81,6 +81,13 @@ class Note(models.Model): if not self.slug and self.name: # only generate a slug if the name has been set, and slug hasn't self.slug = defaultfilters.slugify(self.name) + + # Check if Note.uploaded_at is after Course.updated_at + if self.uploaded_at and self.uploaded_at > self.course.updated_at: + self.course.updated_at = self.uploaded_at + # if it is, update Course.updated_at + self.course.save() + super(Note, self).save(*args, **kwargs) def get_absolute_url(self):