From: Bryan Bonvallet Date: Fri, 9 Jan 2015 22:31:36 +0000 (-0500) Subject: school note counts now parse through departments X-Git-Tag: release-20150131~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=57c0252ee05a489f6218652efd8d85df830003bf;p=oweals%2Fkarmaworld.git school note counts now parse through departments for #377 --- 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): """