Ignore:
Timestamp:
13 Mar 2017, 11:52:24 (8 years ago)
Author:
Henrik Bettermann
Message:

Extend CustomStudentStudyCourseExporter?.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/export.py

    r14595 r14622  
    5050
    5151    fields = tuple(
    52         sorted(iface_names(ICustomStudentStudyCourse))) + ('student_id',)
     52        sorted(iface_names(ICustomStudentStudyCourse))) + (
     53            'matric_number', 'state', 'student_id',)
     54
     55    def mangle_value(self, value, name, context=None):
     56        if name == 'certificate' and value is not None:
     57            # XXX: hopefully cert codes are unique site-wide
     58            value = value.code
     59        if name in ('student_id', 'matric_number', 'state') and context is not None:
     60            student = context.student
     61            value = getattr(student, name, None)
     62        return ExporterBase().mangle_value(value, name, context=context)
    5363
    5464class CustomCourseTicketExporter(NigeriaCourseTicketExporter):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py

    r14595 r14622  
    1111    CustomStudentStudyLevelExporter,
    1212    CustomCourseTicketExporter,
    13     LevelReportDataExporter)
     13    LevelReportDataExporter,
     14    CustomStudentStudyCourseExporter)
    1415from waeup.aaue.testing import FunctionalLayer
    1516
     
    122123        return
    123124
     125class CustomStudentStudyCourseExporterTest(StudentImportExportSetup):
     126
     127    layer = FunctionalLayer
     128
     129    def setUp(self):
     130        super(CustomStudentStudyCourseExporterTest, self).setUp()
     131        self.setup_for_export()
     132        return
     133
     134    def test_export_all(self):
     135        self.setup_student(self.student)
     136        exporter = CustomStudentStudyCourseExporter()
     137        exporter.export_all(self.app, self.outfile)
     138        result = open(self.outfile, 'rb').read()
     139        self.assertEqual(
     140            result,
     141            'certificate,current_level,current_session,current_verdict,'
     142            'entry_mode,entry_session,imported_cgpa,previous_verdict,'
     143            'matric_number,state,student_id\r\n'
     144            'CERT1,200,2012,0,ug_ft,2010,,0,234,created,A111111\r\n'
     145            )
     146        return
     147
     148
    124149class CustomStudentStudyLevelExporterTest(StudentImportExportSetup):
    125150
Note: See TracChangeset for help on using the changeset viewer.