Changeset 10044 for main


Ignore:
Timestamp:
22 Mar 2013, 12:59:13 (12 years ago)
Author:
Henrik Bettermann
Message:

Extend get_students_by_course and return school fee paid in that session.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py

    r10043 r10044  
    171171        self.assertEqual(result, None)
    172172        result = server.get_students_by_course('CRS1', '2012')
    173         self.assertEqual(result, [['K1000000', '234', 'my adviser'],])
     173        self.assertEqual(result, [['K1000000', '234', 'my adviser', 0],])
    174174        result = server.get_students_by_course('CRS1')
    175         self.assertEqual(result, [['K1000000', '234', 'my adviser'],])
     175        self.assertEqual(result, [['K1000000', '234', 'my adviser', 0],])
     176        payment = StudentOnlinePayment()
     177        payment.p_id = 'my-id'
     178        payment.p_session = 2012
     179        payment.amount_auth = 12.12
     180        payment.p_state = u'paid'
     181        self.student['payments']['my-payment'] = payment
     182        result = server.get_students_by_course('CRS1')
     183        self.assertEqual(result, [['K1000000', '234', 'my adviser', 12.12],])
    176184        REQUEST_XML="""\
    177185<?xml version="1.0"?>
     
    195203<value><string>234</string></value>
    196204<value><string>my adviser</string></value>
     205<value><double>12.12</double></value>
    197206</data></array></value>
    198207</data></array></value>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py

    r10043 r10044  
    109109    def get_students_by_course(self, course=None, session=None):
    110110        """2. What STUDENTS registered (student id / matric no)
    111         for course Z in session Y?
     111        for course Z in session Y and did they pay school fee?
    112112
    113113        """
     
    130130            return None
    131131        hitlist = []
    132         for ticket in coursetickets:
     132        for c_ticket in coursetickets:
     133            amount = 0
     134            for p_ticket in c_ticket.student['payments'].values():
     135                if p_ticket.p_state == 'paid' and \
     136                    p_ticket.p_category == 'schoolfee' and \
     137                    p_ticket.p_session == c_ticket.__parent__.level_session:
     138                    amount = p_ticket.amount_auth
    133139            hitlist.append((
    134                 ticket.student.student_id,
    135                 ticket.student.matric_number,
    136                 ticket.__parent__.validated_by))
     140                c_ticket.student.student_id,
     141                c_ticket.student.matric_number,
     142                c_ticket.__parent__.validated_by,
     143                amount
     144                ))
    137145        return list(set(hitlist))
    138146
Note: See TracChangeset for help on using the changeset viewer.