=== modified file 'src/schooltool/gradebook/browser/gradebook.py' --- src/schooltool/gradebook/browser/gradebook.py 2009-11-11 09:36:12 +0000 +++ src/schooltool/gradebook/browser/gradebook.py 2009-11-17 18:13:49 +0000 @@ -247,7 +247,7 @@ url += '/gradebook' else: url += '/mygrades' - title = '%s - %s' % (list(section.courses)[0].title, section.title) + title = '%s - %s' % (", ".join([course.title for course in section.courses]), section.title) css = 'inactive-menu-item' if section == currentSection: css = 'active-menu-item' @@ -272,7 +272,7 @@ def getCurrentSection(self): section = ISection(proxy.removeSecurityProxy(self.context)) - return '%s - %s' % (list(section.courses)[0].title, section.title) + return '%s - %s' % (", ".join([course.title for course in section.courses]), section.title) def getCurrentTerm(self): section = ISection(proxy.removeSecurityProxy(self.context)) @@ -282,7 +282,10 @@ def handleTermChange(self): if 'currentTerm' in self.request: currentSection = ISection(proxy.removeSecurityProxy(self.context)) - currentCourse = list(currentSection.courses)[0] + try: + currentCourse = list(currentSection.courses)[0] + except (IndexError,): + currentCourse = None currentTerm = ITerm(currentSection) requestTermId = self.request['currentTerm'] if requestTermId != self.getTermId(currentTerm): @@ -290,7 +293,11 @@ for section in self.getUserSections(): term = ITerm(section) if self.getTermId(term) == requestTermId: - if currentCourse == list(section.courses)[0]: + try: + temp = list(section.courses)[0] + except (IndexError,): + temp = None + if currentCourse == temp: newSection = section break if newSection is None: @@ -1060,7 +1067,7 @@ 'worksheet': gradebook.context.title, 'student': '%s %s' % (self.context.student.first_name, self.context.student.last_name), - 'section': '%s - %s' % (list(gradebook.section.courses)[0].title, + 'section': '%s - %s' % (", ".join([course.title for course in gradebook.section.courses]), gradebook.section.title), } self.title = _('$worksheet for $student in $section', mapping=mapping)