Ignore:
Timestamp:
8 Jun 2020, 10:54:31 (5 years ago)
Author:
Henrik Bettermann
Message:

Add webservice to check if graduated student exists.

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

    r15811 r16110  
    248248<value><string>1234</string></value>
    249249<value><string>aa@aa.ng</string></value>
     250</data></array></value>
     251</param>
     252</params>
     253</methodResponse>
     254"""
     255        xmlout = self.XMLRPC_post(REQUEST_XML)
     256        self.assertEqual(xmlout, RESPONSE_XML)
     257        return
     258
     259    def test_get_grad_student(self):
     260        server = ServerProxy('http://localhost/app')
     261        self.setup_student(self.student)
     262        result = server.get_grad_student('123', 'aa@aa.ng')
     263        self.assertEqual(result,
     264            [True, False])
     265        REQUEST_XML = """\
     266<?xml version="1.0"?>
     267<methodCall>
     268<methodName>get_grad_student</methodName>
     269<params>
     270<param>
     271<value><string>K1000000</string></value>
     272</param>
     273<param>
     274<value><string>aa@aa.ng</string></value>
     275</param>
     276</params>
     277</methodCall>"""
     278        RESPONSE_XML = """\
     279<?xml version='1.0'?>
     280<methodResponse>
     281<params>
     282<param>
     283<value><array><data>
     284<value><boolean>1</boolean></value>
     285<value><boolean>0</boolean></value>
    250286</data></array></value>
    251287</param>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py

    r15811 r16110  
    2323from zope.catalog.interfaces import ICatalog
    2424from waeup.kofa.interfaces import (
    25     IUniversity, IExtFileStore, IFileStoreNameChooser, IKofaUtils
    26     )
     25    IUniversity, IExtFileStore, IFileStoreNameChooser, IKofaUtils,
     26    GRADUATED)
    2727from waeup.kofa.utils.helpers import get_fileformat, to_timezone
    2828from waeup.kofa.students.catalog import StudentsQuery
     
    163163        return [student.display_fullname, student.certcode,
    164164            student.phone, student.email]
     165
     166    @grok.require('waeup.Public')
     167    def get_grad_student(self, identifier=None, email=None):
     168        """Does student record exist and is graduated student with correct
     169        email address?
     170        """
     171        students = self.context['students']
     172        student = get_student(students, identifier)
     173        if student is None:
     174            return None
     175        correct_email = False
     176        has_graduated = False
     177        if student.email == email:
     178            correct_email = True
     179        if student.state == GRADUATED:
     180            has_graduated = True
     181        return [correct_email, has_graduated]
    165182
    166183    @grok.require('waeup.xmlrpc')
Note: See TracChangeset for help on using the changeset viewer.