modify models.Note.get_absolute_url to generate note urls
authorSeth Woodworth <seth@sethish.com>
Tue, 15 Jan 2013 02:16:59 +0000 (21:16 -0500)
committerSeth Woodworth <seth@sethish.com>
Tue, 15 Jan 2013 02:16:59 +0000 (21:16 -0500)
karmaworld/apps/notes/models.py

index 1198418313140e9f4482011a05e4a17664a6a83c..fd6cd804c361a33065bc38631754c5fa129ce12f 100644 (file)
@@ -50,9 +50,11 @@ class Note(models.Model):
     #course      = models.ForeignKey(Course, blank=True, null=True, related_name="files")
     #school      = models.ForeignKey(School, blank=True, null=True)
 
+
     def __unicode__(self):
         return u"{0}: {1} -- {2}".format(self.file_type, self.name, self.uploaded_at)
 
+
     def save(self, *args, **kwargs):
         """ override built-in save to ensure contextual self.name """
         # TODO: If self.name isn't set, generate one based on uploaded_name
@@ -62,15 +64,12 @@ class Note(models.Model):
             self.slug = defaultfilters.slugify(self.name)
         super(Note, self).save(*args, **kwargs)
 
-    @models.permalink
+
     def get_absolute_url(self):
         """ Resolve note url, use 'note' route and slug if slug
             otherwise use note and id
         """
-        if self.slug:
-            return ('note_detail', [unicode(self.slug)])
-        else:
-            return ('note_detail', [self.id])
+        return u"/{0}/{1}/{2}".format(self.course.school.slug, self.course.slug, self.slug)
 
 
 # FIXME: replace the following GOOGLE_USER in a settings.py