source: WAeUP_SRP/trunk/skins/waeup_unilorin/getAccommodationInfo.py @ 15505

Last change on this file since 15505 was 4008, checked in by Henrik Bettermann, 16 years ago

distinguish between booking_allowed and booking_disabled (tested for uniben and futminna)

fix getMemberInfo.py

File size: 3.2 KB
RevLine 
[3690]1## Script (Python) "getAccommodationInfo"
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
8##title=
9##
10# $Id: getAccommodationInfo.py 1726 2007-05-02 06:21:50Z henrik $
11"""
12return Info about the current Student
13"""
14import logging
15logger = logging.getLogger('Skins.getAccommodationInfo')
16import DateTime
17
[4007]18booking_disabled = True
19
[3690]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
44info['error'] = None
45info['matric_no']=student_record.matric_no
46info['jamb_reg_no']=student_record.jamb_reg_no
47info['name']=student_record.name
48info['email']=student_record.email
49info['level']=student_record.level
50info['verdict']=getattr(student_record,'verdict','')
51review_state = info['review_state'] = student_record.review_state
52info['session'] = session = context.getSessionId()
53students_object = context.portal_url.getPortalObject().campus.students
54student = getattr(students_object, student_id)
55info['student_id'] = student_id
56info['student'] = student
57
[4007]58# do not change these settings!
59
[3690]60booking_allowed = False
[4007]61info['booking_disabled'] = False
[3690]62
63# customize from here
64
65try:
66    level = int(student_record.level)
67except:
68    logger.info('%s has invalid level %s' % (student_id,student_record.level))
69    info['acco'] = None
70    info['booking_allowed'] = False
71    info['student_status'] = ''
72    return info   
73
74if review_state in ('school_fee_paid','courses_registered', 'courses_validated',) and student_record.session == session[0]:
75    info['booking_allowed'] = True
76    info['online_payment'] = True
77else:
78    info['acco'] = None
79    info['booking_allowed'] = False
80    info['student_status'] = ''
81    return info
82
83d = {}
84if level >= 300:
85   bt = 'fi'
86if level == 100:
87    bt = 'fr'
88elif level < 100:
89    bt = 'pr'   
90elif level < 300:
91    bt = 're'
92
93d['sex'] = 'male'
94if student_record.sex:
95    d['sex'] = 'female'
96
97
98info['sex']=d['sex']
99d['bt'] = bt
100student_status = "%(sex)s_%(bt)s" % d
101info['student_status'] = student_status
[4007]102
103# customize end
104
105acco_id = 'accommodation_' + session[0]
106acco = getattr(student,acco_id,None)
107info['acco'] = acco
108info['acco_id'] = acco_id
109info['maintenance_paid'] = False
110if acco is not None:
111    info['acco_doc'] = acco.getContent()
112    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
113    info['maintenance_paid'] = info['acco_review_state'] == "maintenance_fee_paid"
114elif booking_disabled:
115    info['booking_disabled'] = True
116    logger.info('%s: %s eligible but booking disabled' % (student_id,student_status))
117   
[3690]118return info
119
Note: See TracBrowser for help on using the repository browser.