Ignore:
Timestamp:
5 Oct 2021, 20:03:55 (3 years ago)
Author:
Henrik Bettermann
Message:

Add department and faculty title to CustomStudentPaymentExporter?.

File:
1 edited

Legend:

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

    r16403 r16665  
    7272            ICustomStudentOnlinePayment, exclude_attribs=False,
    7373            omit=['display_item']))) + (
    74             'student_id','state','current_session', 'entry_session')
     74            'student_id','state','current_session', 'entry_session',
     75            'faculty', 'department')
    7576
     77    def mangle_value(self, value, name, context=None):
     78        """The mangler determines the student's id, registration
     79        state and current session.
     80        """
     81        if context is not None:
     82            student = context.student
     83            if name in ['faculty', 'department'] and student is not None:
     84                try:
     85                    if name == 'department':
     86                        value = student['studycourse'].certificate.__parent__.__parent__.title
     87                    else:
     88                        value = student['studycourse'].certificate.__parent__.__parent__.__parent__.title
     89                except AttributeError:
     90                    value = 'N/A'
     91        return super(
     92            CustomStudentPaymentExporter, self).mangle_value(
     93            value, name, context=context)
     94
Note: See TracChangeset for help on using the changeset viewer.