From b702dcd7525a949b47cd9102bb979053e5181cdc Mon Sep 17 00:00:00 2001 From: Seth Woodworth Date: Wed, 22 May 2013 16:43:11 -0400 Subject: [PATCH] adding note count to homepage intro text --- karmaworld/apps/courses/views.py | 4 ++++ karmaworld/templates/courses/course_list.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/karmaworld/apps/courses/views.py b/karmaworld/apps/courses/views.py index 9964f9f..cc6fe00 100644 --- a/karmaworld/apps/courses/views.py +++ b/karmaworld/apps/courses/views.py @@ -15,6 +15,7 @@ from django.views.generic.list import ListView from karmaworld.apps.courses.forms import CourseForm from karmaworld.apps.courses.models import Course from karmaworld.apps.courses.models import School +from karmaworld.apps.notes.models import Note class CourseListView(ListView, ModelFormMixin, ProcessFormView): @@ -27,6 +28,9 @@ class CourseListView(ListView, ModelFormMixin, ProcessFormView): """ Add the CourseForm to ListView context """ # get the original context context = super(CourseListView, self).get_context_data(**kwargs) + # get the total number of notes + context['note_count'] = Note.objects.count() + # get the course form for the form at the bottom of the homepage context['course_form'] = kwargs.get('course_form', CourseForm()) if context['course_form'].errors: # if there was an error in the form diff --git a/karmaworld/templates/courses/course_list.html b/karmaworld/templates/courses/course_list.html index cc18a4b..cf1f258 100644 --- a/karmaworld/templates/courses/course_list.html +++ b/karmaworld/templates/courses/course_list.html @@ -98,7 +98,7 @@ $(document).ready(function() {
Pieter J. Smits, from The Noun Project - Share and access a growing database of college lecture notes + Access a growing database of {{ note_count }} college lecture notes
-- 2.25.1