Changeset 10017


Ignore:
Timestamp:
12 Mar 2013, 09:24:07 (12 years ago)
Author:
Henrik Bettermann
Message:

Filter course tickets correctly.

File:
1 edited

Legend:

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

    r9984 r10017  
    6262    """Get course tickets of `students`.
    6363
    64     If code is passed through filter course tickets
    65     which belong to this course code.
     64    If code is passed through, filter course tickets
     65    which belong to this course code and meets level
     66    and level_session.
    6667    """
    6768    tickets = []
    6869    code = kw.get('code', None)
     70    level = kw.get('level', None)
     71    level_session = kw.get('level_session', None)
    6972    if code is None:
    70         for level in get_levels(students):
    71             for ticket in level.values():
     73        for level_obj in get_levels(students):
     74            for ticket in level_obj.values():
    7275                tickets.append(ticket)
    7376    else:
    74         for level in get_levels(students):
    75             for ticket in level.values():
    76                 if ticket.code == code:
    77                     tickets.append(ticket)
     77        for level_obj in get_levels(students):
     78            for ticket in level_obj.values():
     79                if ticket.code != code:
     80                    continue
     81                if level is not None and int(level) != level_obj.level:
     82                    continue
     83                if level_session is not None and \
     84                    int(level_session) != level_obj.level_session:
     85                    continue
     86                tickets.append(ticket)
    7887    return tickets
    7988
Note: See TracChangeset for help on using the changeset viewer.