adding links from the course_list template to the course_detail page
authorSeth Woodworth <seth@sethish.com>
Tue, 15 Jan 2013 02:08:41 +0000 (21:08 -0500)
committerSeth Woodworth <seth@sethish.com>
Tue, 15 Jan 2013 02:08:41 +0000 (21:08 -0500)
karmaworld/apps/courses/models.py
karmaworld/templates/courses/course_list.html

index 374249114c01ab3a3a25f6cfa2f0ad0862034b12..a83af3bf4201d5262d00c076b49d142c067811a7 100644 (file)
@@ -22,13 +22,10 @@ class School(models.Model):
     # Facebook keeps a unique identifier for all schools
     facebook_id = models.BigIntegerField(blank=True, null=True)
 
+
     def __unicode__(self):
         return self.name
 
-    @models.permalink
-    def get_absolute_url(self):
-        """ Not implemented yet """
-        pass
 
     def save(self, *args, **kwargs):
         """ Save school and generate a slug if one doesn't exist """
@@ -57,16 +54,19 @@ class Course(models.Model):
 
     created_at      = models.DateTimeField(auto_now_add=True)
 
+
     class Meta:
         ordering = ['-file_count', 'school', 'name']
 
+
     def __unicode__(self):
         return u"{0}: {1}".format(self.name, self.school)
 
-    @models.permalink
+
     def get_absolute_url(self):
         """ Not implemented yet """
-        pass
+        return u"/{0}/{1}".format(self.school.slug, self.slug)
+
 
     def save(self, *args, **kwargs):
         """ Save school and generate a slug if one doesn't exist """
@@ -74,6 +74,7 @@ class Course(models.Model):
             self.slug = defaultfilters.slugify(self.name)
         super(Course, self).save(*args, **kwargs)
 
+
     def update_note_count(self):
         self.file_count = self.note_set.count()
         self.save()
index d2db158e1373062b81d4873a0771227806beb32a..535fd132125db408cf097e2a5f0124a786e2a159 100644 (file)
@@ -55,7 +55,7 @@ console.log('tablesorter called');
         {% for course in object_list %}
           <tr>
             <td> {{ course.school.name }} </td>
-            <td> {{ course.name }} </td>
+            <td> <a href="{{ course.get_absolute_url }}">{{ course.name }}</a> </td>
             <td> {{ course.instructor_name }} </td>
             <td> {{ course.file_count }} </td>
             <td> {{ course.updated_at|date:"gA // D M d o" }} </td>