Changeset 7004


Ignore:
Timestamp:
6 Nov 2011, 08:52:36 (13 years ago)
Author:
Henrik Bettermann
Message:

Prepare selection of bed for customization.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7003 r7004  
    5050from waeup.sirp.students.vocabularies import StudyLevelSource
    5151from waeup.sirp.students.utils import (
    52     getPaymentDetails, getAccommodationDetails,)
     52    getPaymentDetails, getAccommodationDetails, selectBed)
    5353from waeup.sirp.browser.resources import toggleall
    5454from waeup.sirp.authentication import get_principal_role_manager
     
    10911091        return getAccommodationDetails(student)
    10921092
     1093    # To be sepezified in customization packages
     1094    def selectBed(self, student):
     1095        return getAccommodationDetails(student)
     1096
    10931097    def update(self, SUBMIT=None):
    10941098        student = self.context.getStudent()
     
    10981102            self.redirect(self.url(self.context))
    10991103            return
     1104        if str(student['studycourse'].entry_session) in self.context.keys():
     1105            self.flash('Ticket for %d already created.'
     1106                % student['studycourse'].entry_session)
     1107            self.redirect(self.url(self.context))
     1108            return
    11001109        self.ac_series = self.request.form.get('ac_series', None)
    11011110        self.ac_number = self.request.form.get('ac_number', None)
    1102 
    11031111        if SUBMIT is None:
    11041112            return
     
    11211129        entries = cat.searchResults(
    11221130            owner=(student.student_id,student.student_id))
     1131        # Cannot happen but anyway ...
    11231132        if len(entries):
    11241133            bed = [entry for entry in entries][0]
     
    11431152        bedticket.booking_session = acc_details['booking_session']
    11441153        bedticket.bed_type = acc_details['bt']
    1145         bed = available_beds[0] # first bed found
     1154        bed = selectBed(available_beds)
    11461155        bed.bookBed(student.student_id)
    1147         bedticket.bed = bed # maybe wo don't need the bed object itself
     1156        bedticket.bed = bed # maybe wo don't need the bed object itself and can
     1157                            # remove that later
    11481158        hall_title = bed.__parent__.hostel_name
    11491159        coordinates = bed.getBedCoordinates()[1:]
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r6996 r7004  
    2121    return
    2222
    23 # To be specified in customization packages.
     23# To be specified in customization packages, see also view which
     24# calls the function.
    2425# This function is for demonstration and testing only.
    2526def getPaymentDetails(category, student):
     
    4546        d['amount'] = academic_session.fee_2
    4647    elif category == 'bed_allocation':
    47         d['p_item'] = getBedType(student)
     48        d['p_item'] = getAccommodationDetails(student)['bt']
    4849        d['amount'] = academic_session.booking_fee
    4950    return d
    5051
    51 # To be specified in customization packages.
     52# To be specified in customization packages, see also view which
     53# calls the function.
    5254# This function is for demonstration and testing only.
    5355def getAccommodationDetails(student):
     
    7678    d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
    7779    return d
     80
     81# To be specified in customization packages, see also view which
     82# calls the function.
     83# I the standard configuration we select the first bed found,
     84# but can also randomize the selection if we like.
     85def selectBed(available_beds):
     86    return available_beds[0]
Note: See TracChangeset for help on using the changeset viewer.