Ignore:
Timestamp:
26 Oct 2023, 12:55:48 (14 months ago)
Author:
Henrik Bettermann
Message:

Export faculty and department long titles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/export.py

    r16706 r17622  
    3131    NigeriaStudentStudyLevelExporter,
    3232    NigeriaCourseTicketExporter,
    33     NigeriaStudentPaymentExporter)
     33    NigeriaStudentPaymentExporter,
     34    NigeriaDataForBursaryExporter,
     35    )
     36from waeup.kofa.students.export import StudentPaymentExporter
    3437from waeup.kofa.utils.helpers import iface_names
    3538
     
    129132            value, name, context=context)
    130133
     134class CustomDataForBursaryExporter(NigeriaDataForBursaryExporter):
     135    """
     136    """
     137
     138    fields = tuple(
     139        sorted(iface_names(
     140            ICustomStudentOnlinePayment, exclude_attribs=False,
     141            omit=['display_item', 'certificate', 'student']))) + (
     142            'student_id','matric_number','reg_number',
     143            'firstname', 'middlename', 'lastname','sex',
     144            'state','current_session',
     145            'entry_session', 'entry_mode',
     146            'faculty','department','certcode','lga')
     147
     148
     149    def mangle_value(self, value, name, context=None):
     150        """The mangler fetches the student data.
     151        """
     152        if context is not None:
     153            student = context.student
     154            if name in [
     155                'student_id','matric_number', 'reg_number',
     156                'firstname', 'middlename', 'lastname','sex',
     157                'state', 'current_session',
     158                'entry_session', 'entry_mode',
     159                'certcode',
     160                'lga'] and student is not None:
     161                value = getattr(student, name, None)
     162            certificate = student['studycourse'].certificate
     163            if name == 'department' and certificate is not None:
     164                value = certificate.__parent__.__parent__.longtitle
     165            if name == 'faculty' and certificate is not None:
     166                value = certificate.__parent__.__parent__.__parent__.longtitle
     167        return super(
     168            StudentPaymentExporter, self).mangle_value(
     169            value, name, context=context)
Note: See TracChangeset for help on using the changeset viewer.