source: WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py @ 1418

Last change on this file since 1418 was 1412, checked in by joachim, 18 years ago

more documentation

M profiles/default/schemas/acco_hall.xml
M profiles/default/schemas/schema.xsl
M profiles/default/workflows/waeup_student_wf/definition.xml
M profiles/default/layouts/layout.xsl
M profiles/default/layouts/acco_bed_booking.xml
M profiles/default/layouts/acco_hall.xml
M profiles/default/types/Student.xml
M profiles/default/types/AccoFolder.xml
M profiles/default/types/AccoHall.xml
M doc/srp_documentation.mm

reserved bed functionallity,
pay hostel-fee for reserved bed

D skins/waeup_student/reserve_accommodation.py
M skins/waeup_accommodation/book_reserved_bed.py
A skins/waeup_accommodation/reserve_accommodation.py

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1##parameters=REQUEST
2# $Id: book_reserved_bed.py 1412 2007-02-13 14:14:44Z joachim $
3"""
4process the the accommodation reservation
5"""
6import DateTime
7current = DateTime.DateTime()
8pr = context.portal_registration
9wftool = context.portal_workflow
10lt = context.portal_layouts
11mtool = context.portal_membership
12member = mtool.getAuthenticatedMember()
13acco_cat = context.portal_accommodation
14import logging
15logger = logging.getLogger('Accommodation')
16
17mode = 'create'
18validate = REQUEST.has_key("cpsdocument_edit_button") and\
19           REQUEST.get("cpsdocument_edit_button").startswith('reserve')
20d = {}
21rendered,psm,ds = lt.renderLayout(layout_id= 'acco_bed_booking',
22                      schema_id= 'acco_bed_booking',
23                      context=context,
24                      mapping=validate and REQUEST,
25                      ob=d,
26                      layout_mode='edit',
27                      commit = False
28                      )
29if psm == 'invalid':
30    psm = "Please correct your input."
31    return context.book_reserved_bed_form(rendered = rendered,
32                                 psm = psm,
33                                 #psm = "%s, %s" % (psm,ds),
34                                 mode = mode,
35                                 formaction = "book_reserved_bed",
36                                 button = "reserve bed",
37                                 ds = ds,
38                                 )
39elif psm == '':
40    return context.book_reserved_bed_form(rendered = rendered,
41                                 psm = psm,
42                                 mode = mode,
43                                 formaction = "book_reserved_bed",
44                                 button = "reserve bed",
45                                 ds = ds,
46                                 )
47elif psm == 'valid':
48    pass
49#from Products.zdb import set_trace;set_trace()
50hall_id = context.getId()
51doc = context.getContent()
52student = ds.get('student')
53sid = ds.get('student_id')
54br = ds.get('block_room')
55block = br[0]
56bl = ds.get('bed_letter')
57bid = "%s_%s_%s" % (hall_id,br,bl)
58res = acco_cat(bed = bid)
59psm = ''
60while True:
61    if not res:
62        psm = "No bed with id %s" % bid
63        break
64    bed_brain = res[0]
65    already = acco_cat(student=sid)
66    if already:
67        psm = "Student %s already reserved bed %s" % (sid, already[0].bed)
68        break
69    if not bed_brain.bed_type.endswith("reserved"):
70        psm = "Not a reserved bed %s" % bid
71        break
72    if bed_brain.student:
73        psm = "Bed %s already reserved for %s" % (bid,bed_brain.student)
74        break
75    if student.sex and not block in doc.blocks_for_female:
76        psm = "Sex does not match %s" % bid
77        break
78    break
79if psm != '':
80    return context.book_reserved_bed_form(rendered = rendered,
81                                 psm = psm,
82                                 mode = mode,
83                                 ds = ds,
84                                 formaction = "book_reserved_bed",
85                                 button = "reserve bed",
86                                 )
87acco_cat.modifyRecord(bed = bid, student = sid)
88logger.info('"%s","booked reserved bed %s for","%s"' % (member,bid,sid))
89return context.book_reserved_bed_form(rendered = "",
90                                 psm = "Bed reserved for %s %s" % (sid,student.name),
91                                 mode = mode,
92                                 formaction = "book_reserved_bed",
93                                 button = "next reservation",
94                                 ds = ds,
95                                 )
96
Note: See TracBrowser for help on using the repository browser.