From 57c0252ee05a489f6218652efd8d85df830003bf Mon Sep 17 00:00:00 2001 From: Bryan Bonvallet Date: Fri, 9 Jan 2015 17:31:36 -0500 Subject: [PATCH] school note counts now parse through departments for #377 --- karmaworld/apps/courses/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/karmaworld/apps/courses/models.py b/karmaworld/apps/courses/models.py index 778d2b4..13b39d7 100644 --- a/karmaworld/apps/courses/models.py +++ b/karmaworld/apps/courses/models.py @@ -92,10 +92,15 @@ class School(models.Model): """ Update the School.file_count by summing the contained course.file_count """ - self.file_count = sum([course.file_count for course in self.course_set.all()]) + # find all courses without a department + course_list = list(self.course_set.all()) + # find all courses with a department + for department in self.department_set.all(): + for course in department.course_set.all(): + course_list.append(course) + self.file_count = sum([course.file_count for course in course_list]) self.save() - @register_channel_name('school_object_by_name') class SchoolLookup(AnonLookupChannel): """ -- 2.25.1