[1567] | 1 | ##parameters=REQUEST |
---|
| 2 | # $Id: fixReservedBeds.py 1447 2007-02-20 13:41:26Z joachim $ |
---|
| 3 | """ |
---|
| 4 | process the the accommodation reservation |
---|
| 5 | """ |
---|
| 6 | import DateTime |
---|
| 7 | current = DateTime.DateTime() |
---|
| 8 | request = context.REQUEST |
---|
| 9 | pr = context.portal_registration |
---|
| 10 | wftool = context.portal_workflow |
---|
| 11 | lt = context.portal_layouts |
---|
| 12 | mtool = context.portal_membership |
---|
| 13 | member = mtool.getAuthenticatedMember() |
---|
| 14 | acco_cat = context.portal_accommodation |
---|
| 15 | import logging |
---|
| 16 | logger = logging.getLogger('Skins.fixReservedBed') |
---|
| 17 | students = context.portal_url.getPortalObject().campus.students |
---|
| 18 | hostels = context.portal_url.getPortalObject().campus.accommodation.objectItems() |
---|
| 19 | acco_id = "accommodation_%s" % context.getSessionId() |
---|
| 20 | logger.info('%s starts fixReservedBeds' % (member)) |
---|
| 21 | #from Products.zdb import set_trace;set_trace() |
---|
| 22 | for h_id,h in hostels: |
---|
| 23 | h_doc = h.getContent() |
---|
| 24 | reserved = context.reservedRoomsVoc(doc=h_doc) |
---|
| 25 | for hr,hrv in reserved: |
---|
| 26 | for k,v in context.getAccoHallBeds(doc=h_doc): |
---|
| 27 | bid = "%s_%s_%s" % (h_id,hr,k) |
---|
| 28 | res = acco_cat(bed = bid) |
---|
| 29 | if not res: |
---|
| 30 | continue |
---|
| 31 | bed = res[0] |
---|
| 32 | if not bed.student: |
---|
| 33 | continue |
---|
| 34 | student_obj = getattr(students,bed.student) |
---|
| 35 | if acco_id in student_obj.objectIds(): |
---|
| 36 | acco_doc = getattr(student_obj, acco_id).getContent() |
---|
| 37 | if acco_doc.bed != bid: |
---|
| 38 | acco_cat.modifyRecord(bed=bid,student = '') |
---|
| 39 | logger.info('"%s","removed allocation of %s for","%s"' % (member,bid,bed.student)) |
---|
| 40 | logger.info('%s finishes fixReservedBeds' % (member)) |
---|
| 41 | return request.RESPONSE.redirect("%s" % context.absolute_url()) |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | |
---|