source: WAeUP_SRP/trunk/skins/waeup_student/getMemberInfo.py @ 16202

Last change on this file since 16202 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.1 KB
Line 
1## Script (Python) "getMemberInfo"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: getApplicationInfo.py 1161 2006-12-31 07:50:50Z henrik $
11"""
12return Info about the current Student
13"""
14import logging
15logger = logging.getLogger('Student.Member.Info')
16
17request = context.REQUEST
18mtool = context.portal_membership
19wf = context.portal_workflow
20member = mtool.getAuthenticatedMember()
21member_id = str(member)
22path_info = request.get('PATH_INFO').split('/')
23# if mtool.isAnonymousUser():
24#     return None
25# info = {}
26# requested_id = context.getStudentId()
27# if requested_id and not context.isStaff() and member_id != requested_id:
28#     logger.info('%s tried to access personal object of %s' % (member_id,requested_id))
29#     student_id = requested_id
30#     return None
31# elif context.isStaff():
32#     student_id = requested_id
33# else:
34#     student_id = member_id
35
36info = context.waeup_tool.getAccessInfo(context)
37student_id = info['student_id']
38if student_id is None:
39    return None
40
41students_object = context.portal_url.getPortalObject().campus.students
42student = getattr(students_object, student_id)
43
44complete_msg="""
45Your SRP Member Details
46-----------------------
47
48Fullname: %(student_name)s
49Student Id: %(id)s
50Matriculation Number: %(matric_no)s
51Registration Number: %(jamb_reg_no)s
52Registration Status: %(review_state)s
53Email Address in Application Data: %(app_email)s
54Email Address in Personal Data: %(per_email)s
55Date of Birth: %(birthday)s
56Password: '%(password)s'
57
58"""
59short_msg="""
60Your SRP Member Details
61-----------------------
62
63Fullname: %(student_name)s
64Student Id: %(id)s
65Password: %(password)s
66
67"""
68student_record = context.students_catalog.getRecordByKey(student_id)
69if hasattr(student,"application") and hasattr(student,"personal") and hasattr(student,"clearance"):
70    #info['student'] = student
71    info['id'] = student_id
72    info['review_state'] = student_record.review_state
73    #info['per'] = getattr(student,'personal',None)
74    #per_doc = info['per_doc'] = student.personal.getContent()
75    #info['app_doc'] = student.application.getContent()
76    info['jamb_reg_no'] = student_record.jamb_reg_no
77    #info['clear_doc'] = student.clearance.getContent()
78    info['matric_no'] = student_record.matric_no
79    info['password'] = context.waeup_tool.getCredential(student_id)
80    info['student_name'] = student_record.name
81    info['birthday'] = student.clearance.getContent().birthday
82    app_email = info['app_email'] = student.application.getContent().app_email
83    per_email = info['per_email'] = student_record.email
84    if per_email:
85        info['email'] = per_email
86    elif app_email:
87        info['email'] = app_email
88    else:
89        info['email'] = ''
90
91    info['message'] = complete_msg % info
92    info['with_email'] = bool(info['email'])
93else:
94    info['student_name'] = 'N/A'
95    info['id'] = student_id
96    info['review_state'] = wf.getInfoFor(student,'review_state',None)
97    info['password'] = context.waeup_tool.getCredential(student_id)
98    info['email'] = 'N/A'
99    info['message'] = short_msg % info
100    info['with_email'] = False
101return info
Note: See TracBrowser for help on using the repository browser.