Ignore:
Timestamp:
21 Mar 2013, 10:57:48 (12 years ago)
Author:
Henrik Bettermann
Message:

Also matric or reg numbers can be used as student identifiers.

File:
1 edited

Legend:

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

    r10040 r10041  
    2222from waeup.kofa.interfaces import IUniversity
    2323
     24def get_student(students, identifier):
     25    if identifier is None:
     26        return None
     27    student = students.get(identifier, None)
     28    if student is None:
     29        cat = queryUtility(ICatalog, name='students_catalog')
     30        results = list(
     31            cat.searchResults(matric_number=(identifier, identifier)))
     32        if len(results) == 1:
     33            student = results[0]
     34        else:
     35            results = list(
     36                cat.searchResults(reg_number=(identifier, identifier)))
     37            if len(results) == 1:
     38                student = results[0]
     39    return student
    2440
    2541#class XMLRPCPermission(grok.Permission):
     
    6177
    6278    @grok.require('waeup.xmlrpc')
    63     def get_courses_by_session(self, student_id=None, session=None):
     79    def get_courses_by_session(self, identifier=None, session=None):
    6480        """What COURSES are registered by student X in session Y?
    6581
    6682        """
    67         if student_id is None:
     83        students = self.context['students']
     84        student = get_student(students, identifier)
     85        if student is None:
    6886            return None
    69         student = self.context['students'].get(student_id, None)
    70         if student is None:
    71             return  None
    7287        try:
    7388            session = int(session)
Note: See TracChangeset for help on using the changeset viewer.