1 | ## Script (Python) "viewAccommodationRecord"
|
---|
2 | ##bind container=container
|
---|
3 | ##bind context=context
|
---|
4 | ##bind namespace=
|
---|
5 | ##bind script=script
|
---|
6 | ##bind subpath=traverse_subpath
|
---|
7 | ##parameters=student_id=None,session=None
|
---|
8 | ##title=
|
---|
9 | ##
|
---|
10 | # $Id: viewAccommodationRecord.py 5816 2011-03-07 17:41:48Z henrik $
|
---|
11 | """
|
---|
12 | """
|
---|
13 | import logging
|
---|
14 | logger = logging.getLogger('Skins.viewAccommodationRecords')
|
---|
15 | import DateTime
|
---|
16 |
|
---|
17 | pprops = context.portal_properties
|
---|
18 | booking_disabled = not pprops.enable_acco_booking
|
---|
19 |
|
---|
20 | request = context.REQUEST
|
---|
21 | mtool = context.portal_membership
|
---|
22 | wf = context.portal_workflow
|
---|
23 | member = mtool.getAuthenticatedMember()
|
---|
24 | member_id = str(member)
|
---|
25 | path_info = request.get('PATH_INFO').split('/')
|
---|
26 |
|
---|
27 | if mtool.isAnonymousUser():
|
---|
28 | return None
|
---|
29 | info = {}
|
---|
30 | if student_id is None:
|
---|
31 | requested_id = context.getStudentId()
|
---|
32 | if requested_id and not context.isStaff() and member_id != requested_id:
|
---|
33 | logger.info('%s tried to access %s' % (member_id,requested_id))
|
---|
34 | return None
|
---|
35 | elif context.isStaff():
|
---|
36 | student_id = requested_id
|
---|
37 | else:
|
---|
38 | student_id = member_id
|
---|
39 | student_record = context.students_catalog.getRecordByKey(student_id)
|
---|
40 | if student_record is None:
|
---|
41 | logger.info('%s not found in students_catalog' % student_id)
|
---|
42 | return None
|
---|
43 |
|
---|
44 | student_path = "%s/campus/students/%s" % (context.portal_url(),student_id)
|
---|
45 |
|
---|
46 | if session:
|
---|
47 | accommodation_records = context.accommodation_catalog(student_id = student_id, session = session)
|
---|
48 | accommodation = []
|
---|
49 | ar = accommodation_records[0]
|
---|
50 | info = {}
|
---|
51 | fields = {
|
---|
52 | 'Hostel Application Date':'acco_res_date',
|
---|
53 | 'Hostel Application PIN':'acco_res_sc_pin',
|
---|
54 | 'Bed':'bed',
|
---|
55 | 'Booking Session':'session',
|
---|
56 | 'Bed Type':'student_status',
|
---|
57 | 'Maintenance Payment Date':'acco_maint_date',
|
---|
58 | 'Maintenance Payment Code':'acco_maint_code',
|
---|
59 | 'Hostel Maintenance PIN':'acco_maint_sc_pin',
|
---|
60 | 'Online Payment Id':'acco_maint_pay_id',
|
---|
61 | 'Maintenance Fee':'acco_maint_fee',
|
---|
62 | 'Booking Status':'reservation_status'
|
---|
63 | }
|
---|
64 | #info['url'] = student_path
|
---|
65 | for field in fields:
|
---|
66 | info[field] = getattr(ar,fields[field],None)
|
---|
67 |
|
---|
68 | return context.accommodation_record_slip(
|
---|
69 | info = info,
|
---|
70 | )
|
---|
71 |
|
---|
72 |
|
---|
73 | |
---|