Ignore:
Timestamp:
3 Feb 2021, 21:26:18 (4 years ago)
Author:
Henrik Bettermann
Message:

Change webservice.

File:
1 edited

Legend:

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

    r16391 r16392  
    155155
    156156    @grok.require('waeup.xmlrpc')
    157     def get_students_by_department(self, faccode=None, depcode=None, session=None):
    158         """A webservice to pull student's registered courses in a department.
     157    def get_students_by_department(self, faccode=None, depcode=None,
     158                                   session=None, level=None):
     159        """A webservice to pull student's registered courses in a
     160        department
    159161        """
    160162        try:
    161163            session = int(session)
     164            level = int(level)
    162165        except (TypeError, ValueError):
    163166            pass
    164         sessionsearch = True
    165167        if session in (None, ''):
    166             sessionsearch = False
     168            session= None
     169        if level in (None, ''):
     170            level= None
    167171        try:
    168172            department =self.context['faculties'][faccode][depcode]
     
    171175        courses = department.courses.keys()
    172176        cat = queryUtility(ICatalog, name='coursetickets_catalog')
    173         hitlist = []
     177        hitdict = {}
    174178        for course in courses:
    175             if sessionsearch:
    176                 coursetickets = cat.searchResults(
    177                     session=(session, session),
    178                     code=(course, course))
    179             else:
    180                 coursetickets = cat.searchResults(
    181                     code=(course, course))
     179            coursetickets = cat.searchResults(
     180                session=(session, session),
     181                level=(level, level),
     182                code=(course, course))
    182183            for c_ticket in coursetickets:
    183                 hitlist.append((
    184                     c_ticket.code,
    185                     c_ticket.level,
    186                     c_ticket.level_session,
    187                     c_ticket.student.student_id,
    188                     c_ticket.student.matric_number,
    189                     c_ticket.student.display_fullname,
    190                     ))
    191         return list(set(hitlist))
     184                if not c_ticket.student.student_id in hitdict.keys():
     185                    hitdict[c_ticket.student.student_id] = (
     186                        c_ticket.student.matric_number,
     187                        c_ticket.student.display_fullname,
     188                        [c_ticket.code,])
     189                else:
     190                    hitdict[c_ticket.student.student_id][2].append(
     191                        c_ticket.code,)
     192        return hitdict
    192193
    193194    @grok.require('waeup.xmlrpc')
Note: See TracChangeset for help on using the changeset viewer.