source: WAeUP_SRP/trunk/skins/waeup_fceokene/getAccommodationStatus.py @ 6515

Last change on this file since 6515 was 5788, checked in by Henrik Bettermann, 14 years ago

Do not log bokking_allowed status.

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1## Script (Python) "getAccommodationStatus"
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: getAccommodationStatus.py 5788 2011-03-02 12:05:36Z henrik $
11"""
12return Info about the current Student
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19
20import logging
21logger = logging.getLogger('Skins.getAccommodationStatus')
22import DateTime
23
24pprops = context.portal_properties
25booking_disabled = not pprops.enable_acco_booking
26
27request = context.REQUEST
28mtool = context.portal_membership
29wf = context.portal_workflow
30member = mtool.getAuthenticatedMember()
31member_id = str(member)
32path_info = request.get('PATH_INFO').split('/')
33
34if mtool.isAnonymousUser():
35    return None
36info = {}
37if student_id is None:
38    requested_id = context.getStudentId()
39    if requested_id and not context.isStaff() and member_id != requested_id:
40        logger.info('%s tried to access %s' % (member_id,requested_id))
41        return None
42    elif context.isStaff():
43        student_id = requested_id
44    else:
45        student_id = member_id
46student_record = context.students_catalog.getRecordByKey(student_id)
47if student_record is None:
48    logger.info('%s not found in students_catalog' % student_id)
49    return None
50
51info['error'] = None
52info['matric_no']=student_record.matric_no
53info['jamb_reg_no']=student_record.jamb_reg_no
54info['name']=student_record.name
55info['email']=student_record.email
56info['level']=student_record.level
57info['verdict']=getattr(student_record,'verdict','')
58review_state = info['review_state'] = student_record.review_state
59info['session'] = session = context.getSessionId()
60students_object = context.portal_url.getPortalObject().campus.students
61student = getattr(students_object, student_id)
62info['student_id'] = student_id
63info['student'] = student
64
65# do not change these settings!
66
67booking_allowed = False
68info['booking_disabled'] = False
69
70# customize from here
71
72try:
73    level = int(student_record.level)
74except:
75    logger.info('%s has invalid level %s' % (student_id,student_record.level))
76    info['acco'] = None
77    info['booking_allowed'] = False
78    info['student_status'] = ''
79    return info   
80
81try:
82    arrived = int(student_record.session) == int(session[0])
83except:
84    arrived = False
85    logger.info('%s has invalid session %s' % (student_id,student_record.session))
86
87if review_state in ('school_fee_paid','courses_registered', 'courses_validated',) and arrived:
88    info['booking_allowed'] = True
89    info['online_payment'] = True
90else:
91    info['acco'] = None
92    info['booking_allowed'] = False
93    info['student_status'] = ''
94    #logger.info('%s: not eligible' % (student_id)) 
95    return info
96
97d = {}
98if level >= 300:
99   bt = 'fi'
100if level == 100:
101    bt = 'fr'
102elif level < 100:
103    bt = 'pr'   
104elif level < 300:
105    bt = 're'
106
107d['sex'] = 'male'
108if student_record.sex:
109    d['sex'] = 'female'
110
111
112info['sex']=d['sex']
113d['bt'] = bt
114student_status = "%(sex)s_%(bt)s" % d
115info['student_status'] = student_status
116
117# customize end
118
119acco_id = student_id + '|' + session[0]
120info['acco_id'] = acco_id
121
122if booking_disabled:
123  info['booking_disabled'] = True
124  #logger.info('%s: %s eligible but booking disabled' % (student_id,student_status)) 
125
126accommodation_record = context.accommodation_catalog.getRecordByKey(acco_id)
127if accommodation_record is None:
128    return info
129 
130info['booking_allowed'] = False
131info['acco_res_date'] = accommodation_record.acco_res_date
132info['acco_res_sc_pin'] = accommodation_record.acco_res_sc_pin
133info['acco_maint_fee'] = accommodation_record.acco_maint_fee
134info['acco_maint_code'] = accommodation_record.acco_maint_code
135info['student_status'] = accommodation_record.student_status
136info['bed'] = accommodation_record.bed
137info['session'] = accommodation_record.session
138info['maintenance_paid'] = accommodation_record.reservation_status == 'maintenance_fee_paid'
139
140return info
Note: See TracBrowser for help on using the repository browser.