Changeset 17862 for main


Ignore:
Timestamp:
29 Jul 2024, 14:01:38 (5 months ago)
Author:
Henrik Bettermann
Message:

Mangle exporter values.

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

Legend:

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

    r17852 r17862  
    2020import grok
    2121from datetime import datetime
     22from waeup.kofa.interfaces import IKofaUtils
     23from zope.component import getUtility
    2224from waeup.uniben.students.interfaces import (
    2325    ICustomStudent,
     
    197199        'lg_area',
    198200        'current_mode',
    199         'certcode',
     201        'certificate',
    200202        'faccode',
    201203        'depcode',
     
    204206        'current_verdict',
    205207        'entry_session',
    206         'faccode',
    207         'depcode',
    208         'certcode',
    209208        'nysc_verdict',
    210209        'nysc_senate_info',
     
    223222
    224223    def mangle_value(self, value, name, context=None):
     224        verdicts = getUtility(IKofaUtils).VERDICTS_DICT
    225225        if name in ('lg_state', 'lg_area') and context.lga:
    226226            value = context.lga
     
    231231            if name == 'lg_area':
    232232                value = '-'.join(value.split('_')[1:])
     233        if name == 'certificate':
     234            cert = getattr(context.get('studycourse', None), 'certificate', None)
     235            if cert is not None:
     236                value = cert.title
     237        if name == 'nysc_verdict' and value:
     238            value = verdicts[value]
    233239        return super(
    234240            NYSCExporter, self).mangle_value(
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_export.py

    r17852 r17862  
    178178        self.setup_student(self.student)
    179179        self.student.nysc = True
     180        self.student.nysc_verdict = 'B'
    180181        self.student.nysc_processed = False
    181182        self.student.lga = u'cross_river_abc'
     
    185186        self.assertMatches(
    186187            'student_id,matric_number,reg_number,firstname,middlename,lastname,'
    187             'sex,nationality,date_of_birth,state,lg_state,lg_area,current_mode,certcode,faccode,'
    188             'depcode,current_level,current_session,current_verdict,'
    189             'entry_session,faccode,depcode,certcode,nysc_verdict,'
    190             'nysc_senate_info,nysc_date_of_graduation,nysc_updated,nysc_processed,%s\r\n'
    191             'A111111,234,123,Anna,M.,Tester,f,NG,1981-02-04#,created,cross-river,abc,ug_ft,'
    192             'CERT1,NA,NA,200,2012,0,2010,NA,NA,CERT1,,,,,0,,,,,,12.12,,,,,,\r\n' % year_range_str,
     188            'sex,nationality,date_of_birth,state,lg_state,lg_area,current_mode,'
     189            'certificate,faccode,depcode,current_level,current_session,'
     190            'current_verdict,entry_session,nysc_verdict,nysc_senate_info,'
     191            'nysc_date_of_graduation,nysc_updated,nysc_processed,%s\r\n'
     192            'A111111,234,123,Anna,M.,Tester,f,NG,1981-02-04#,created,'
     193            'cross-river,abc,ug_ft,Unnamed Certificate,NA,NA,200,2012,0,2010,'
     194            'Student with carryover courses,,,,0,,,,,,'
     195            '12.12,,,,,,\r\n' % year_range_str,
    193196            result
    194197            )
Note: See TracChangeset for help on using the changeset viewer.