Ignore:
Timestamp:
12 Feb 2008, 20:03:59 (17 years ago)
Author:
Henrik Bettermann
Message:

add psm

do not release bed if bed change fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py

    r3150 r3151  
    3535    if info['acco'] is None:
    3636        logger.info('No accommodation object for %s' % (student_id))
    37         return redirect("%s/%s" % (students.absolute_url(),student_id))
     37        return redirect("%s/%s/no_booking_allowed" % (students.absolute_url(),student_id))
    3838    res = beds(student=student_id)
    3939    status = info['student_status']
     
    4343    else:
    4444        allocated_bed = res[0]
    45         #student = student_id
    46         if allocated_bed.bed_type == status:
    47             logger.info('Status %s of %s has not changed' % (status,student_id))
    48             return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
    49         logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status))
    50         beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
    51         logger.info('Bed %s released' % (allocated_bed.bed))
    5245    code,bed = beds.searchAndReserveBed(student_id,status)
    5346    if code > 0:
     47        if res:
     48            if allocated_bed.bed_type == status:
     49                logger.info('Status %s of %s has not changed' % (status,student_id))
     50                psm='Student status has not changed!'
     51                return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
     52            logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status))
     53            beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
     54            logger.info('Bed %s released' % (allocated_bed.bed))   
    5455        d = {}
    5556        d['bed'] = bed
     
    6162        acco_doc.edit(mapping=d)
    6263        logger.info('Bed %s allocated to %s' % (bed,student_id))
    63         return redirect("%s/%s/%s" % (students.absolute_url(),student_id,info['acco_id']))
    64     # student_obj = getattr(students,student_id)
    65     # acco_id = "accommodation_%s" % context.getSessionId()[0]
    66     # if acco_id in student_obj.objectIds():
    67     #     acco_doc = getattr(student_obj, acco_id).getContent()
    68     #     if acco_doc.bed == bed:
    69     #         acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
    70     acco_doc = info['acco_doc']
    71     if acco_doc.bed == bed:
    72         acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
     64        psm='Bed changed!'
     65        return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
     66    #acco_doc = info['acco_doc']
     67    #acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
    7368    logger.info('New bed allocation for %s failed, code = %s' % (student_id,code))
    74     logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id))
    75     return redirect("%s/%s/%s" % (students.absolute_url(),student_id,info['acco_id']))
     69    #logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id))
     70    psm='Bed change failed!'
     71    return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
    7672
    7773info = {}
Note: See TracChangeset for help on using the changeset viewer.