Ignore:
Timestamp:
6 Jan 2016, 08:21:17 (9 years ago)
Author:
Henrik Bettermann
Message:

Add matric_number to export file.

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

    r12876 r13569  
    1818"""Exporters for student related stuff.
    1919"""
     20from waeup.kofa.utils.batching import ExporterBase
    2021from waeup.aaue.students.interfaces import (
    2122    ICustomStudent, ICustomStudentStudyCourse,
     
    5152    fields = tuple(sorted(iface_names(ICustomCourseTicket) +
    5253        ['level', 'code', 'level_session'])) + ('student_id',
    53         'certcode', 'display_fullname')
     54        'certcode', 'display_fullname', 'matric_number')
     55
     56    def mangle_value(self, value, name, context=None):
     57        """The mangler determines the student's id and fullname.
     58        """
     59        if context is not None:
     60            student = context.student
     61            if name in ('student_id', 'display_fullname', 'matric_number') \
     62                and student is not None:
     63                value = getattr(student, name, None)
     64        return ExporterBase().mangle_value(value, name, context=context)
    5465
    5566class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py

    r13351 r13569  
    88from waeup.aaue.students.export import (
    99    CustomStudentExporter, CustomStudentPaymentExporter,
    10     CustomStudentStudyLevelExporter)
     10    CustomStudentStudyLevelExporter,
     11    CustomCourseTicketExporter)
    1112from waeup.aaue.testing import FunctionalLayer
    1213
     
    141142        return
    142143
     144class CustomCourseTicketExporterTest(StudentImportExportSetup):
     145
     146    layer = FunctionalLayer
     147
     148    def setUp(self):
     149        super(CustomCourseTicketExporterTest, self).setUp()
     150        self.setup_for_export()
     151        return
     152
     153    def test_export_all(self):
     154        # we can really export all course tickets
     155        # set values we can expect in export file
     156        self.setup_student(self.student)
     157        exporter = CustomCourseTicketExporter()
     158        exporter.export_all(self.app, self.outfile)
     159        result = open(self.outfile, 'rb').read()
     160        self.assertEqual(
     161            result,
     162            'automatic,carry_over,code,credits,dcode,fcode,level,level_session,'
     163            'mandatory,passmark,score,semester,title,student_id,certcode,'
     164            'display_fullname,matric_number\r\n'
     165            '1,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'
     166            'Anna M. Tester,234\r\n'
     167            )
     168        return
     169
Note: See TracChangeset for help on using the changeset viewer.