Changeset 3043


Ignore:
Timestamp:
24 Jan 2008, 18:02:36 (17 years ago)
Author:
joachim
Message:

update bedlist now modyfies beds, if they have been modyfied. Change beds
now sets the previous bed student to not_occupied.

Location:
WAeUP_SRP/base
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Accommodation.py

    r2867 r3043  
    3838        generate the free Bedslist.
    3939        """
    40         freelist = self.portal_accommodation
     40        bed_list = self.portal_accommodation
    4141        l = self.portal_catalog({'meta_type': "AccoHall"})
    4242        halls = []
    4343        generated = []
    4444        generated.append('"Bed","BedType","Student"' % vars())
     45        modyfied = []
     46        modyfied.append('"Bed","BedType","Student"' % vars())
    4547        beds_generated = []
    4648        for h in l:
     
    5254            hall_gen['name'] = hall.Title
    5355            count = 0
     56            modyfied_count = 0
    5457            reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',hall_doc.reserved_rooms)
    5558                                     if r]
    5659            #for block in range(1,int(hall_doc.nr_of_blocks)+1):
    5760            # for block in 'ABCDEFGHIJ'[:int(hall_doc.nr_of_blocks)]:
    58             if set(hall_doc.blocks_for_female).intersection(set(hall_doc.blocks_for_male)):
     61            blocks_for_female = getattr(hall_doc,'blocks_for_female',[])
     62            blocks_for_male = getattr(hall_doc,'blocks_for_male',[])
     63            beds_for_fresh = getattr(hall_doc,'beds_for_fresh',[])
     64            beds_for_pre = getattr(hall_doc,'beds_for_pre',[])
     65            beds_for_final = getattr(hall_doc,'beds_for_final',[])
     66            if set(blocks_for_female).intersection(set(blocks_for_male)):
    5967                return self.accommodation.acco_folder_view(beds_generated=beds_generated)
    60             for block in hall_doc.blocks_for_female + hall_doc.blocks_for_male:
     68            for block in blocks_for_female + blocks_for_male:
    6169                sex = 'male'
    62                 if block in hall_doc.blocks_for_female:
     70                if block in blocks_for_female:
    6371                    sex = 'female'
    6472                for floor in range(1,int(hall_doc.nr_of_floors)+1):
     
    7179                            elif hall_doc.special_handling and not hall_doc.special_handling.startswith("no"):
    7280                                bt = hall_doc.special_handling
    73                             elif bed in hall_doc.beds_for_fresh:
     81                            elif bed in beds_for_fresh:
    7482                                bt = 'fr'
    75                             elif bed in hall_doc.beds_for_pre:
     83                            elif bed in beds_for_pre:
    7684                                bt = 'pr'
    77                             elif bed in hall_doc.beds_for_final:
     85                            elif bed in beds_for_final:
    7886                                bt = 'fi'
    7987                            if hall_doc.special_handling.startswith("no_"):
     
    8694                            d['sort_id'] = getattr(hall_doc,'sort_id',0)
    8795                            d['hall'] = hall.getId()
    88                             d['student'] = NOT_OCCUPIED
    89                             try:
    90                                 #freelist.addRecord(bed = uid, bed_type = bt,hall = hall.getId())
    91                                 freelist.addRecord(**d)
     96                            bed_record = bed_list.getRecordByKey(uid)
     97                            if bed_record is None:
     98                                d['student'] = NOT_OCCUPIED
     99                                bed_list.addRecord(**d)
    92100                                count +=1
    93101                                generated.append('"%(uid)s","%(bt)s"' % vars())
    94                             except ValueError:
    95                                 #freelist.modifyRecord(bed = uid, bed_type = bt,hall =hall.getId())
    96                                 #freelist.modifyRecord(**d)
     102                            elif bed_record.bed_type != bt:
     103                                bed_list.modifyRecord(**d)
     104                                modyfied.append('"%(uid)s","%(bt)s"' % vars())
     105                                modyfied_count += 1
    97106                                pass
    98107            hall_gen['count']= count
     108            hall_gen['modyfied_count']= modyfied_count
    99109            beds_generated.append(hall_gen)
    100110        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
    101111        open("%s/import/bedlist_%s.csv" % (i_home,current),"w+").write('\n'.join(generated))
     112        open("%s/import/bedlist_modyfied_%s.csv" % (i_home,current),"w+").write('\n'.join(modyfied))
    102113        return self.accommodation.acco_folder_view(beds_generated=beds_generated)
    103 
    104 ###)
     114    ###)
    105115
    106116    security.declareProtected(ModifyPortalContent,"importReservedBeds")###(
  • WAeUP_SRP/base/WAeUPTables.py

    r3018 r3043  
    482482    name = "portal_accommodation"
    483483    key = "bed"
     484    not_occupied = NOT_OCCUPIED
    484485    def __init__(self,name=None):
    485486        if name ==  None:
     
    487488        WAeUPTable.__init__(self, name)
    488489
    489     def searchAndReserveBed(self, student_id,bed_type):
     490    def searchAndReserveBed(self, student_id,bed_type): ###(
    490491        #records = self.searchResults({'student' : student_id})
    491492        #import pdb;pdb.set_trace()
     
    504505        s_logger.info('%s reserved bed %s' % (student_id,rec.bed))
    505506        return 1,rec.bed
     507    ###)
    506508
    507509
  • WAeUP_SRP/base/skins/waeup_accommodation/acco_folder_view.pt

    r2890 r3043  
    2222        <tr>
    2323          <th width="200px">Hall Name</th>
    24           <th>New Beds Generated</th>
     24          <th>Beds Generated</th>
     25          <th>Beds Modyfied</th>
    2526        </tr>
    2627        <tr tal:repeat="hall beds_generated">
    2728          <td tal:content="hall/name"></td>
    2829          <td tal:content="hall/count"></td>
     30          <td tal:content="hall/modyfied_count"></td>
    2931        </tr>
    3032      </table>
  • WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py

    r2454 r3043  
    4444        return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
    4545    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='')
     46    beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
    4747    logger.info('Bed %s released' % (allocated_bed.bed))
    4848    code,bed = beds.searchAndReserveBed(student_id,status)
Note: See TracChangeset for help on using the changeset viewer.