source: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/fixReservedBeds.py @ 15554

Last change on this file since 15554 was 1596, checked in by joachim, 18 years ago

merged changes from trunk to joachim-event-branch

File size: 1.6 KB
Line 
1##parameters=REQUEST
2# $Id: fixReservedBeds.py 1447 2007-02-20 13:41:26Z joachim $
3"""
4process the the accommodation reservation
5"""
6import DateTime
7current = DateTime.DateTime()
8request = context.REQUEST
9pr = context.portal_registration
10wftool = context.portal_workflow
11lt = context.portal_layouts
12mtool = context.portal_membership
13member = mtool.getAuthenticatedMember()
14acco_cat = context.portal_accommodation
15import logging
16logger = logging.getLogger('Skins.fixReservedBed')
17students = context.portal_url.getPortalObject().campus.students
18hostels = context.portal_url.getPortalObject().campus.accommodation.objectItems()
19acco_id = "accommodation_%s" % context.getSessionId()
20logger.info('%s starts fixReservedBeds' % (member))
21#from Products.zdb import set_trace;set_trace()
22for 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))
40logger.info('%s finishes fixReservedBeds' % (member))
41return request.RESPONSE.redirect("%s" % context.absolute_url())
42
43
44
45
Note: See TracBrowser for help on using the repository browser.