Changeset 16665


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

Add department and faculty title to CustomStudentPaymentExporter?.

Location:
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students
Files:
2 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
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/tests/test_export.py

    r16434 r16665  
    8080            'r_amount_approved,r_card_num,r_code,r_company,r_desc,'
    8181            'r_pay_reference,thirdparty_amt,student_id,state,'
    82             'current_session,entry_session\r\n'
     82            'current_session,entry_session,faculty,department\r\n'
    8383            '666,12.12,%s-04-01 13:12:01#,,,schoolfee,[],1,my-id,p-item,'
    8484            '100,first,%s,paid,%s-04-01 14:12:01#,,12.12,'
    85             '789,r-code,interswitch,,,,A111111,created,2012,2010\r\n'
     85            '789,r-code,interswitch,,,,A111111,created,2012,2010,'
     86            'Unnamed Faculty,Unnamed Department\r\n'
    8687            % (curr_year-6, curr_year-6, curr_year-6), result
    8788            )
Note: See TracChangeset for help on using the changeset viewer.