Changeset 3406


Ignore:
Timestamp:
2 Apr 2008, 07:16:08 (17 years ago)
Author:
Henrik Bettermann
Message:

WAeUPTool.py: fix traceback

Accommodation.py: enable import of reserved beds

release_bed.py: remove maintenance fee

reserve_accommodation.py: enable bed change for reserved beds. To be done: check for existing acco object before creating it in line 128

change_bed.py: enable bed change for reserved beds

Location:
WAeUP_SRP/base
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Accommodation.py

    r3043 r3406  
    203203                    psm = "Not a reserved bed"
    204204                    break
    205                 if bed_brain.student:
     205                if bed_brain.student and bed_brain.student != NOT_OCCUPIED:
    206206                    psm = "Bed %s already reserved for %s" % (bid,bed_brain.student)
    207207                    break
  • WAeUP_SRP/base/WAeUPTables.py

    r3362 r3406  
    489489
    490490    def searchAndReserveBed(self, student_id,bed_type): ###(
    491         #records = self.searchResults({'student' : student_id})
    492         #import pdb;pdb.set_trace()
     491        logger = logging.getLogger('WAeUPTables.AccommodationTable.searchAndReserveBed')
    493492        records = self.evalAdvancedQuery(Eq('student',student_id))
    494         if len(records) > 0:
    495             return -1,"Student with Id %s already booked bed %s." % (student_id,records[0].bed)
    496 
    497         #records = [r for r in self.searchResults({'bed_type' : bed_type}) if not r.student]
     493        if len(records) == 1:
     494            #return -1,"Student with Id %s already booked bed %s." % (student_id,records[0].bed)
     495            logger.info('%s found (reserved) bed %s' % (student_id,records[0].bed))
     496            return -1,records[0].bed
     497        elif len(records) > 1:
     498            logger.info('%s found more than one (reserved) bed' % (student_id))
     499            return -3,'more than one bed'           
    498500        query = Eq('bed_type',bed_type) & Eq('student',NOT_OCCUPIED)
    499501        records = self.evalAdvancedQuery(query,sortSpecs=('sort_id','bed'))
    500502        if len(records) == 0:
    501             return -2,"No bed available"
     503            logger.info('No bed %s available for %s' % (bed_type,student_id))
     504            return -2,"no bed"
    502505        rec = records[0]
    503506        self.modifyRecord(bed=rec.bed,student=student_id)
    504         s_logger = logging.getLogger('WAeUPTables.AccommodationTable.searchAndReserveBed')
    505         s_logger.info('%s reserved bed %s' % (student_id,rec.bed))
     507        logger.info('%s booked bed %s' % (student_id,rec.bed))
    506508        return 1,rec.bed
    507509    ###)
  • WAeUP_SRP/base/WAeUPTool.py

    r3391 r3406  
    11751175        """return Hall Info"""
    11761176        info = {}
    1177         hall,block,room,letter = bed.split('_')
     1177        bedsplit = bed.split('_')
     1178        if len(bedsplit) == 4:
     1179            hall,block,room,letter = bed.split('_')
     1180        else:
     1181            info['maintenance_code'] = 'None'
     1182            return info
    11781183        res = ZCatalog.searchResults(self.portal_catalog_real,portal_type="AccoHall",id=hall)
    11791184        if res and len(res) == 1:
  • WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py

    r3206 r3406  
    4343            psm = 'No bed allocated for %s' % (student_id)
    4444            logger.info(psm)
    45             break
    46         allocated_bed = res[0]
    47         if allocated_bed.bed_type == status:
    48             logger.info('Status %s of %s has not changed.' % (status,student_id))
    49             psm='Student status has not changed!'
    50             break
    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         query = Eq('bed_type',status) & Eq('student',context.portal_accommodation.not_occupied)
    54         records = context.portal_accommodation.evalAdvancedQuery(query)
    55         if len(records) < 1:
    56             psm='Bed change for %s failed, no free bed in category %s.' % (student_id,status)
    57             logger.info(psm)
    58             break
    59         beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
    60         logger.info('Bed %s released' % (allocated_bed.bed))
     45            pass
     46            #break
     47        elif res[0].bed_type.endswith("reserved"):
     48             logger.info('found reserved bed %s' % res[0].bed)
     49             pass       
     50        else:   
     51            allocated_bed = res[0]
     52            if allocated_bed.bed_type == status:
     53                logger.info('Status %s of %s has not changed.' % (status,student_id))
     54                psm='Student status has not changed!'
     55                break
     56                #return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
     57            logger.info('Bed status %s of %s has changed to %s.' % (allocated_bed.bed_type,student_id,status))
     58            query = Eq('bed_type',status) & Eq('student',context.portal_accommodation.not_occupied)
     59            records = context.portal_accommodation.evalAdvancedQuery(query)
     60            if len(records) < 1:
     61                psm='Bed change for %s failed, no free bed in category %s.' % (student_id,status)
     62                logger.info(psm)
     63                break
     64            beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
     65            logger.info('Bed %s released' % (allocated_bed.bed))
    6166        code,bed = beds.searchAndReserveBed(student_id,status)
    62         if code > 0:
     67        if code > -2:
    6368            d = {}
    6469            d['bed'] = bed
     
    7277            psm='Bed changed!'
    7378            break
    74             #return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
    75         #acco_doc = info['acco_doc']
    76         #acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
    7779        logger.info('Bed change for %s failed, code = %s' % (student_id,code))
    78         #logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id))
    7980        psm='Bed change failed!'
     81        break
    8082    return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
    8183
  • WAeUP_SRP/base/skins/waeup_accommodation/release_bed.py

    r3049 r3406  
    4444    acco_cat.modifyRecord(bed=allocated_bed.bed,student=acco_cat.not_occupied)
    4545    acco_doc = context.getContent()
    46     acco_doc.edit(mapping={'bed':"-- cancelled by section officer --"})
     46    acco_doc.edit(mapping={'bed':"-- cancelled by section officer --",'acco_maint_fee':""})
    4747    logger.info('%s released bed of %s' % (member_id,student_id))
    4848    return redirect("%s" % (context.absolute_url()))
  • WAeUP_SRP/base/skins/waeup_student/reserve_accommodation.py

    r3126 r3406  
    108108                break
    109109            if code == -1:
    110                 return context.accommodation_edit_form(rendered = res,
    111                                         psm = "%s" % bed,
    112                                         mode = mode,
    113                                         ds = ds,
    114                                         )
     110                break
     111                #return context.accommodation_edit_form(rendered = res,
     112                #                        psm = "%s" % bed,
     113                #                        mode = mode,
     114                #                        ds = ds,
     115                #                        )
    115116            elif code == -2:
    116117                return context.accommodation_edit_form(rendered = res,
Note: See TracChangeset for help on using the changeset viewer.