Changeset 623 for WAeUP_SRP/trunk


Ignore:
Timestamp:
8 Oct 2006, 17:06:18 (18 years ago)
Author:
joachim
Message:

added generate Bedlist

Location:
WAeUP_SRP/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Accommodation.py

    r622 r623  
    1111from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
    1212from Products.WAeUP_SRP.WAeUPTables import AccommodationTable
     13import Globals
     14import DateTime
     15p_home = Globals.package_home(globals())
     16i_home = Globals.INSTANCE_HOME
    1317
    1418class AccoFolder(CPSDocument): ###(
     
    3034        generate the free Bedslist.
    3135        """
    32         freelist = AccommodationTable()
    33         l = self.portal_catalog({'meta_type': "Accommodation"})
     36        freelist = self.portal_accommodation
     37        l = self.portal_catalog({'meta_type': "AccoHall"})
    3438        halls = []
     39        generated = []
     40        generated.append('"Bed","BedType","Student"' % vars())
    3541        for h in l:
    3642            halls.append(h.getObject())
    3743        for hall in halls:
     44            #import pdb;pdb.set_trace()
    3845            h = hall.getContent()
    3946            reserved = [int(r) for r in h.reserved_rooms.split()]
     
    4754                        for bed in 'ABCDEFGH'[:int(h.beds_per_room)]:
    4855                            room_nr = floor*100 + room
     56                            bt = 'xx'
    4957                            if room_nr in reserved:
    50                                 print room_nr
    51                                 continue
    52                             bt = 'xx'
    53                             if bed in h.beds_for_fresh:
     58                                bt = "reserved"
     59                            elif bed in h.beds_for_fresh:
    5460                                bt = 'fr'
    5561                            elif bed in h.beds_for_returning:
     
    5864                                bt = 'fi'
    5965                            bt = "%(sex)s_%(bt)s" % vars()
    60                             uid = '%s_%d_%s' % (hall.getId(),room_nr,bed)
     66                            uid = '%s_%d_%d_%s' % (hall.getId(),block,room_nr,bed)
    6167                            print bt,uid
    62                             freelist.addRecord(bed = uid)
    63                             try:
    64                                 freelist.modifyRecord(uid, bed = bed, bed_type = bt)
    65                             except ValueError,e:
    66                                 freelist.deleteRecord(uid)
    67 
     68                            freelist.addRecord(bed = uid, bed_type = bt, student= '')
     69                            generated.append('"%(uid)s","%(bt)s"' % vars())
     70        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
     71        open("%s/import/bedlist_%s.csv" % (i_home,current),"w+").write('\n'.join(generated))
    6872        return self.accommodation.academics_contents()
    6973
  • WAeUP_SRP/trunk/profiles/default/types/AccoFolder.xml

    r622 r623  
    3535  <permission value="View"/>
    3636 </action>
    37  <action title="Add Accommodation Hall" action_id="new_entry"
     37<action title="Add Accommodation Hall" action_id="new_entry"
    3838    category="object" condition_expr=""
    3939    url_expr="string:${object_url}/content_create?type_name=AccoHall"
     40    visible="True">
     41  <permission value="Modify portal content"/>
     42 </action>
     43<action title="Generate Bedslist" action_id="new_list"
     44    category="object" condition_expr=""
     45    url_expr="string:${object_url}/generateFreeBedsList"
    4046    visible="True">
    4147  <permission value="Modify portal content"/>
Note: See TracChangeset for help on using the changeset viewer.