Changeset 9744 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 30 Nov 2012, 12:24:13 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r9734 r9744 391 391 StudentsExporter, self).mangle_value( 392 392 value, name, context=context) 393 394 class StudentStudyLevelsOverviewExporter(StudentsExporter): 395 """Exporter for students with study level overview. 396 """ 397 grok.name('studylevelsoverview') 398 399 levels = ['10',] 400 levels += [str(level) for level in range(100,1000,10) if level % 100 < 30] 401 levels.append('999') 402 level_range_tuple = tuple(levels) 403 404 #: Fieldnames considered by this exporter 405 fields = ('student_id', ) + ( 406 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad', 407 'current_level', 'current_session', 408 ) + level_range_tuple 409 410 #: The title under which this exporter will be displayed 411 title = _(u'Student Study Levels Overview') 412 413 def mangle_value(self, value, name, context=None): 414 if name in self.level_range_tuple and context is not None: 415 value = '' 416 for level in context['studycourse'].values(): 417 if level.level == int(name): 418 value = '%s|%s|%s|%s' % ( 419 level.level_session, 420 len(level), 421 level.validated_by, 422 level.level_verdict) 423 break 424 return super( 425 StudentsExporter, self).mangle_value( 426 value, name, context=context) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9734 r9744 8 8 StudentsExporter, StudentStudyCourseExporter, StudentStudyLevelExporter, 9 9 CourseTicketExporter, PaymentsExporter, BedTicketsExporter, 10 StudentPaymentsOverviewExporter, get_students, StudentsExportFilter) 10 StudentPaymentsOverviewExporter, StudentStudyLevelsOverviewExporter, 11 get_students, StudentsExportFilter) 11 12 from waeup.kofa.students.accommodation import BedTicket 12 13 from waeup.kofa.students.interfaces import ICSVStudentExporter … … 643 644 ) 644 645 return 646 647 class StudentStudyLevelsOverviewExporterTest(StudentImportExportSetup): 648 649 layer = FunctionalLayer 650 651 def setUp(self): 652 super(StudentStudyLevelsOverviewExporterTest, self).setUp() 653 self.setup_for_export() 654 return 655 656 def test_ifaces(self): 657 obj = StudentStudyLevelsOverviewExporter() 658 verifyObject(ICSVExporter, obj) 659 verifyClass(ICSVExporter, StudentStudyLevelsOverviewExporter) 660 return 661 662 def test_get_as_utility(self): 663 result = queryUtility(ICSVExporter, name="studylevelsoverview") 664 self.assertTrue(result is not None) 665 return 666 667 def test_export(self): 668 self.setup_student(self.student) 669 exporter = StudentStudyLevelsOverviewExporter() 670 exporter.export([self.student], self.outfile) 671 result = open(self.outfile, 'rb').read() 672 self.assertEqual( 673 'student_id,state,certcode,faccode,depcode,is_postgrad,' 674 'current_level,current_session,' 675 '10,100,110,120,200,210,220,300,310,320,400,410,420,500,' 676 '510,520,600,610,620,700,710,720,800,810,820,900,910,920,999\r\n' 677 'A111111,created,CERT1,NA,NA,0,200,2012,,2012|1|None|A' 678 ',,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n', 679 result 680 ) 681 return 682 683 def test_export_all(self): 684 self.setup_student(self.student) 685 exporter = StudentStudyLevelsOverviewExporter() 686 exporter.export_all(self.app, self.outfile) 687 result = open(self.outfile, 'rb').read() 688 self.assertEqual( 689 'student_id,state,certcode,faccode,depcode,is_postgrad,' 690 'current_level,current_session,' 691 '10,100,110,120,200,210,220,300,310,320,400,410,420,500,' 692 '510,520,600,610,620,700,710,720,800,810,820,900,910,920,999\r\n' 693 'A111111,created,CERT1,NA,NA,0,200,2012,,2012|1|None|A' 694 ',,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n', 695 result 696 ) 697 return
Note: See TracChangeset for help on using the changeset viewer.