Ignore:
Timestamp:
21 Aug 2013, 20:52:03 (11 years ago)
Author:
Henrik Bettermann
Message:

Add webservice which can be used to update user data and enroll user in Moodle courses via webservices.

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

Legend:

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

    r10503 r10521  
    3939        self.assertEqual(result, None)
    4040        return
     41
     42    def test_get_moodle_data(self):
     43        # make sure we can get applicant infos providing valid creds
     44        server = ServerProxy('http://mgr:mgrpw@localhost/app')
     45        self.setup_applicant(self.applicant)
     46        apl_id = self.applicant.applicant_id
     47        result = server.get_applicant_moodle_data(apl_id)
     48        self.assertEqual(
     49            result, {
     50                'lastname': 'Bubble',
     51                'email': 'bob@sample.com',
     52                'firstname': 'Bob',
     53                }
     54            )
     55        return
     56
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/webservices.py

    r10504 r10521  
    1717##
    1818import grok
     19from hurry.query.query import Query
     20from hurry.query import Eq
    1921from zope.component import getUtility
    2022from zope.pluggableauth.interfaces import IAuthenticatorPlugin
     
    5254                    type=principal.user_type,
    5355                    description=principal.description)
     56
     57    @grok.require('waeup.xmlrpc')
     58    def get_applicant_moodle_data(self, identifier=None):
     59        """Returns applicant data to update user data and enroll user
     60        in Moodle courses.
     61
     62        """
     63        results = Query().searchResults(
     64            Eq(('applicants_catalog', 'applicant_id'), identifier))
     65        if not results:
     66            return None
     67        applicant = list(results)[0]
     68        return dict(email=applicant.email,
     69                    firstname=applicant.firstname,
     70                    lastname=applicant.lastname,
     71                    )
Note: See TracChangeset for help on using the changeset viewer.