source: WAeUP_SRP/trunk/skins/waeup_futminna/getAccommodationInfo.py @ 7069

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

Allow 500 level students book for accommodation.

File size: 3.6 KB
RevLine 
[3784]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
[3843]18
[5589]19pprops = context.portal_properties
20booking_disabled = not pprops.enable_acco_booking
21
22
[3784]23request = context.REQUEST
24mtool = context.portal_membership
25wf = context.portal_workflow
26member = mtool.getAuthenticatedMember()
27member_id = str(member)
28path_info = request.get('PATH_INFO').split('/')
29
30if mtool.isAnonymousUser():
31    return None
32info = {}
33if student_id is None:
34    requested_id = context.getStudentId()
35    if requested_id and not context.isStaff() and member_id != requested_id:
36        logger.info('%s tried to access %s' % (member_id,requested_id))
37        return None
38    elif context.isStaff():
39        student_id = requested_id
40    else:
41        student_id = member_id
42student_record = context.students_catalog.getRecordByKey(student_id)
43if student_record is None:
44    logger.info('%s not found in students_catalog' % student_id)
45    return None
46
47info['error'] = None
48info['matric_no']=student_record.matric_no
49info['jamb_reg_no']=student_record.jamb_reg_no
50info['name']=student_record.name
51info['email']=student_record.email
52info['level']=student_record.level
53info['verdict']=getattr(student_record,'verdict','')
54review_state = info['review_state'] = student_record.review_state
55info['session'] = session = context.getSessionId()
56students_object = context.portal_url.getPortalObject().campus.students
57student = getattr(students_object, student_id)
58info['student_id'] = student_id
59info['student'] = student
60
[4007]61# do not change these settings!
62
[3784]63booking_allowed = False
[4007]64info['booking_disabled'] = False
[3784]65
66# customize from here
67
68try:
69    level = int(student_record.level)
70except:
71    logger.info('%s has invalid level %s' % (student_id,student_record.level))
[3795]72    info['acco'] = None
73    info['booking_allowed'] = False
74    info['student_status'] = ''
75    return info   
[5605]76
77if review_state in ('cleared_and_validated','school_fee_paid','courses_registered', 'courses_validated',) and student_record.session == session[0]:
[3795]78    info['booking_allowed'] = True
79    info['online_payment'] = True
[5042]80# returning student can also book without having paid the school fee (see ticket #29)
81#elif review_state == 'returning' and int(student_record.session)+1 == int(session[0]):
82#    info['booking_allowed'] = True
83#    info['online_payment'] = True
[3795]84else:
[3784]85    info['acco'] = None
[3795]86    info['booking_allowed'] = False
[3784]87    info['student_status'] = ''
[4009]88    logger.info('%s: not eligible' % (student_id))
[3784]89    return info
90
[4007]91d = {}
92d['sex'] = 'male'
[5589]93#d['bt'] = 'all'
[4007]94if student_record.sex:
95    d['sex'] = 'female'
[5589]96   
97if level == 100:
[5595]98    bt = 'fr'
[5589]99else:
[5595]100    bt = 're'   
101if student_record.faculty in ('SSE'):
102    bt += "_sse"   
103d['bt'] = bt   
[4007]104
105info['sex']=d['sex']
106student_status = "%(sex)s_%(bt)s" % d
107info['student_status'] = student_status
108
109# customize end
110
[3784]111acco_id = 'accommodation_' + session[0]
112acco = getattr(student,acco_id,None)
113info['acco'] = acco
114info['acco_id'] = acco_id
115info['maintenance_paid'] = False
116if acco is not None:
117    info['acco_doc'] = acco.getContent()
118    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
119    info['maintenance_paid'] = info['acco_review_state'] == "maintenance_fee_paid"
[3843]120elif booking_disabled:
[4007]121    info['booking_disabled'] = True
122    logger.info('%s: %s eligible but booking disabled' % (student_id,student_status))
[3795]123
[3784]124return info
Note: See TracBrowser for help on using the repository browser.