Changeset 10043


Ignore:
Timestamp:
22 Mar 2013, 06:28:08 (12 years ago)
Author:
Henrik Bettermann
Message:

Add one more webservice method.

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

    r10042 r10043  
    1010from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser
    1111from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
     12from waeup.kofa.students.payments import StudentOnlinePayment
    1213from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    1314from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket
     
    268269        xmlout = self.XMLRPC_post(REQUEST_XML)
    269270        self.assertTrue(xmlout.startswith(RESPONSE_XML))
     271
     272    def test_get_paid_sessions(self):
     273        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     274        self.setup_student(self.student)
     275        payment = StudentOnlinePayment()
     276        payment.p_id = 'my-id'
     277        payment.p_session = 2009
     278        payment.amount_auth = 12.12
     279        payment.p_state = u'paid'
     280        self.student['payments']['my-payment'] = payment
     281        result = server.get_paid_sessions('123')
     282        self.assertEqual(result, {'2009': 12.12})
     283        REQUEST_XML="""\
     284<?xml version="1.0"?>
     285<methodCall>
     286<methodName>get_paid_sessions</methodName>
     287<params>
     288<param>
     289<value><string>K1000000</string></value>
     290</param>
     291</params>
     292</methodCall>"""
     293        RESPONSE_XML="""\
     294<?xml version='1.0'?>
     295<methodResponse>
     296<params>
     297<param>
     298<value><struct>
     299<member>
     300<name>2009</name>
     301<value><double>12.12</double></value>
     302</member>
     303</struct></value>
     304</param>
     305</params>
     306</methodResponse>
     307"""
     308        xmlout = self.XMLRPC_post(REQUEST_XML)
     309        self.assertEqual(xmlout, RESPONSE_XML)
     310        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py

    r10042 r10043  
    8080    @grok.require('waeup.xmlrpc')
    8181    def get_courses_by_session(self, identifier=None, session=None):
    82         """What COURSES are registered by student X in session Y?
     82        """1. What COURSES are registered by student X in session Y?
    8383
    8484        """
     
    108108    @grok.require('waeup.xmlrpc')
    109109    def get_students_by_course(self, course=None, session=None):
    110         """What STUDENTS registered (student id / matric no)
     110        """2. What STUDENTS registered (student id / matric no)
    111111        for course Z in session Y?
    112112
    113         (a) Authorized by course adviser.
    114         (b) Not authorized by course adviser.
    115113        """
    116114        try:
     
    141139    @grok.require('waeup.xmlrpc')
    142140    def get_student_info(self, identifier=None):
    143         """Who is the student with matriculation number / student id?
     141        """3a. Who is the student with matriculation number / student id
    144142
    145143        """
     
    153151    @grok.require('waeup.xmlrpc')
    154152    def get_student_passport(self, identifier=None):
    155         """Get passport picture of student with
    156         matriculation number / student id?
     153        """3b. Get passport picture of student with
     154        matriculation number / student id.
    157155
    158156        """
     
    164162            student, attr='passport.jpg')
    165163        return xmlrpclib.Binary(img.read())
     164
     165    @grok.require('waeup.xmlrpc')
     166    def get_paid_sessions(self, identifier=None):
     167        """6. Get list of SESSIONS school fees paid by student X.
     168
     169        """
     170        students = self.context['students']
     171        student = get_student(students, identifier)
     172        if student is None:
     173            return None
     174        payments_dict = {}
     175        for ticket in student['payments'].values():
     176            if ticket.p_state == 'paid' and \
     177                ticket.p_category == 'schoolfee':
     178                payments_dict[str(ticket.p_session)] = ticket.amount_auth
     179        if not payments_dict:
     180            return None
     181        return payments_dict
Note: See TracChangeset for help on using the changeset viewer.