From: Seth Woodworth Date: Tue, 15 Jan 2013 02:08:41 +0000 (-0500) Subject: adding links from the course_list template to the course_detail page X-Git-Tag: release-20150131~557^2~10 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c8630222e7b508495b982f86dc965bf1009fb7e7;p=oweals%2Fkarmaworld.git adding links from the course_list template to the course_detail page --- 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" }}