From c8630222e7b508495b982f86dc965bf1009fb7e7 Mon Sep 17 00:00:00 2001 From: Seth Woodworth Date: Mon, 14 Jan 2013 21:08:41 -0500 Subject: [PATCH] adding links from the course_list template to the course_detail page --- karmaworld/apps/courses/models.py | 13 +++++++------ karmaworld/templates/courses/course_list.html | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/karmaworld/apps/courses/models.py b/karmaworld/apps/courses/models.py index 3742491..a83af3b 100644 --- a/karmaworld/apps/courses/models.py +++ b/karmaworld/apps/courses/models.py @@ -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() diff --git a/karmaworld/templates/courses/course_list.html b/karmaworld/templates/courses/course_list.html index d2db158..535fd13 100644 --- a/karmaworld/templates/courses/course_list.html +++ b/karmaworld/templates/courses/course_list.html @@ -55,7 +55,7 @@ console.log('tablesorter called'); {% for course in object_list %} {{ course.school.name }} - {{ course.name }} + {{ course.name }} {{ course.instructor_name }} {{ course.file_count }} {{ course.updated_at|date:"gA // D M d o" }} -- 2.25.1