on Note.save, if upload date is greater than course.updated_at time, update course...
authorSeth Woodworth <seth@sethish.com>
Mon, 25 Mar 2013 16:41:09 +0000 (12:41 -0400)
committerSeth Woodworth <seth@sethish.com>
Mon, 25 Mar 2013 16:41:09 +0000 (12:41 -0400)
karmaworld/apps/notes/models.py

index 5b34fdc4a11ea6dc13b02fcf5ea4fe088afda03e..877997df0c8a0d9ef7fc2fdc8c8f0fcfb28a9515 100644 (file)
@@ -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):