Changeset 15873 for main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
- Timestamp:
- 9 Dec 2019, 10:44:57 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r15792 r15873 25 25 IExtFileStore, IFileStoreNameChooser, IKofaUtils) 26 26 from waeup.kofa.interfaces import MessageFactory as _ 27 from waeup.kofa.university.interfaces import ICertificateCourse, ICourse 27 28 from waeup.kofa.students.catalog import StudentsQuery, CourseTicketsQuery 28 29 from waeup.kofa.students.interfaces import ( … … 133 134 return tickets 134 135 136 def get_outstanding(students, **kw): 137 """Get students with outstanding certificate courses. 138 """ 139 students_wo = [] 140 for student in students: 141 certificate = getattr( 142 student.get('studycourse', None), 'certificate', None) 143 if certificate: 144 allticketcodes = [] 145 failedticketcodes = '' # taken but failed 146 nottakenticketcodes = '' # registered but not taken 147 missedticketcodes = '' # not registered 148 for level in student['studycourse'].values(): 149 failedticketcodes += level.passed_params[4] 150 nottakenticketcodes += level.passed_params[5] 151 for ticket in level.values(): 152 allticketcodes.append(ticket.code) 153 for certcourse in certificate.values(): 154 if certcourse.getCourseCode() not in allticketcodes: 155 missedticketcodes += '%s ' % certcourse.__name__ 156 student_wo = (student, missedticketcodes, 157 failedticketcodes, nottakenticketcodes) 158 students_wo.append(student_wo) 159 return students_wo 160 135 161 def get_payments(students, p_states=None, **kw): 136 162 """Get all payments of `students` within given payment_date period. … … 430 456 value, name, context=context) 431 457 458 class StudentOutstandingCoursesExporter(grok.GlobalUtility, StudentExporterBase): 459 """The Student Outstanding Courses Exporter first filters the set of 460 students by searching the students catalog. Then it exports students with 461 lists of outstanding courses, i.e. courses which the student has 462 missed (not registered at all), failed (registered but not passed) 463 or nottaken (registered but not taken). 464 """ 465 grok.name('studentoutstandingcourses') 466 467 fields = ('student_id', 'certcode', 'display_fullname','missed', 468 'failed', 'nottaken') 469 title = _(u'Student Outstanding Courses') 470 471 def filter_func(self, x, **kw): 472 return get_outstanding(x, **kw) 473 474 def mangle_value(self, value, name, context=None): 475 """The mangler determines the student's id, fullname and certcode, 476 and it collects the lists of outstanding courses. 477 """ 478 if context is not None: 479 if name in ('student_id', 'display_fullname', 'certcode'): 480 value = getattr(context[0], name, None) 481 elif name == 'missed': 482 value = context[1] 483 elif name == 'failed': 484 value = context[2] 485 elif name == 'nottaken': 486 value = context[3] 487 return super( 488 StudentOutstandingCoursesExporter, self).mangle_value( 489 value, name, context=context) 490 432 491 class StudentPaymentExporter(grok.GlobalUtility, StudentExporterBase): 433 492 """The Student Payment Exporter first filters the set of students
Note: See TracChangeset for help on using the changeset viewer.