source: WAeUP_SRP/trunk/skins/waeup_accommodation/viewAccommodationRecord.py

Last change on this file was 5816, checked in by Henrik Bettermann, 14 years ago

Make entry_mode editable.

  • Property svn:keywords set to Id
File size: 2.3 KB
RevLine 
[5616]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"""
13import logging
[5816]14logger = logging.getLogger('Skins.viewAccommodationRecords')
[5616]15import DateTime
16
17pprops = context.portal_properties
18booking_disabled = not pprops.enable_acco_booking
19
20request = context.REQUEST
21mtool = context.portal_membership
22wf = context.portal_workflow
23member = mtool.getAuthenticatedMember()
24member_id = str(member)
25path_info = request.get('PATH_INFO').split('/')
26
27if mtool.isAnonymousUser():
28    return None
29info = {}
30if 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
39student_record = context.students_catalog.getRecordByKey(student_id)
40if student_record is None:
41    logger.info('%s not found in students_catalog' % student_id)
42    return None
43
44student_path = "%s/campus/students/%s" % (context.portal_url(),student_id)
45
46if 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
68return context.accommodation_record_slip(
69                                info = info,
70                               )
71                 
72   
73   
Note: See TracBrowser for help on using the repository browser.