Changeset 3047


Ignore:
Timestamp:
25 Jan 2008, 09:55:40 (17 years ago)
Author:
joachim
Message:

fix for #69 fceokene,

File:
1 edited

Legend:

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

    r3043 r3047  
    3333    logger.info('%s requests bed change for %s' % (member_id,student_id))
    3434    info = context.getAccommodationInfo(student_id)
     35    if info['acco'] is None:
     36        logger.info('No accommodation object for %s' % (student_id))
     37        return redirect("%s/%s" % (students.absolute_url(),student_id))
    3538    res = beds(student=student_id)
     39    status = info['student_status']
    3640    if len(res) == 0:
    37         logger.info('No bed found for %s' % (student_id))
    38         return redirect("%s/%s" % (students.absolute_url(),student_id))
    39     allocated_bed = res[0]
    40     status = info['student_status']
    41     student = student_id
    42     if allocated_bed.bed_type == status:
    43         logger.info('Status %s of %s has not changed' % (status,student_id))
    44         return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
    45     logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status))
    46     beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
    47     logger.info('Bed %s released' % (allocated_bed.bed))
     41        logger.info('No bed allocated for %s' % (student_id))
     42        #return redirect("%s/%s" % (students.absolute_url(),student_id))
     43    else:
     44        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))
    4852    code,bed = beds.searchAndReserveBed(student_id,status)
    4953    if code > 0:
    50         #from Products.zdb import set_trace; set_trace()
    5154        d = {}
    5255        d['bed'] = bed
     
    5861        acco_doc.edit(mapping=d)
    5962        logger.info('Bed %s allocated to %s' % (bed,student_id))
    60         return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
    61     student_obj = getattr(students,student_id)
    62     acco_id = "accommodation_%s" % context.getSessionId()[0]
    63     if acco_id in student_obj.objectIds():
    64         acco_doc = getattr(student_obj, acco_id).getContent()
    65         if acco_doc.bed == bed:
    66             acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
     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 --"})
    6773    logger.info('New bed allocation for %s failed, code = %s' % (student_id,code))
    6874    logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id))
Note: See TracChangeset for help on using the changeset viewer.