Ignore:
Timestamp:
25 Oct 2012, 09:44:02 (12 years ago)
Author:
Henrik Bettermann
Message:

Reorganize allocation of students to beds. We can't use the StudentSource? in live systems. The select box would be filled with ten thousands of students.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/vocabularies.py

    r9400 r9414  
    2727
    2828NOT_OCCUPIED = u'not occupied'
    29 
    30 class StudentSource(BasicContextualSourceFactory):
    31     """A students source delivers all students in accommodation session.
    32     """
    33 
    34     def acco_students(self, context):
    35         catalog = getUtility(ICatalog, name='students_catalog')
    36         accommodation_session = getSite()['hostels'].accommodation_session
    37         students = catalog.searchResults(current_session=(
    38             accommodation_session,accommodation_session))
    39         existing_students = [
    40             context.__parent__[key].owner
    41             for key in context.__parent__.keys()]
    42         students = [student for student in students
    43                       if not student.student_id in existing_students]
    44         students = sorted(list(students),
    45                           key=lambda value: value.student_id)
    46         return dict([(student.student_id,student.fullname) for student in students])
    47 
    48     def getValues(self, context):
    49         return self.acco_students(context).keys()
    50 
    51     def getToken(self, context, value):
    52         return value
    53 
    54     def getTitle(self, context, value):
    55         return "%s - %s" % (value, self.acco_students(context)[value])
    5629
    5730class SpecialHandlingSource(ContextualDictSourceFactoryBase):
Note: See TracChangeset for help on using the changeset viewer.