source: WAeUP_SRP/base/skins/waeup_student/getMemberInfo.py @ 3427

Last change on this file since 3427 was 3100, checked in by joachim, 17 years ago

fix #457 traceback

File size: 2.9 KB
RevLine 
[1220]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('/')
23if mtool.isAnonymousUser():
24    return None
25info = {}
26requested_id = context.getStudentId()
27if requested_id and not context.isStaff() and member_id != requested_id:
[1571]28    logger.info('%s tried to access personal object of %s' % (member_id,requested_id))
[1220]29    student_id = requested_id
[1571]30    return None
[1220]31elif context.isStaff():
32    student_id = requested_id
33else:
34    student_id = member_id
35
36
37students_object = context.portal_url.getPortalObject().campus.students
38student = getattr(students_object, student_id)
[1223]39
[3100]40if hasattr(student,"application") and hasattr(student,"personal") and hasattr(student,"clearance"):
[1281]41    info['student'] = student
42    info['id'] = student_id
[1871]43    info['review_state'] = context.getStudentReviewState()
[3100]44    info['per'] = getattr(student,'personal',None)
[1281]45    info['app'] = student.application
46    info['per_doc'] = student.personal.getContent()
47    info['app_doc'] = student.application.getContent()
48    info['clear_doc'] = student.clearance.getContent()
49    info['password'] = context.waeup_tool.getCredential(student_id)
50
[2504]51#    if info['per_doc'].email:
52#        info['email'] = info['per_doc'].email
53#    else:
54#        info['email'] = info['app_doc'].app_email
55
56    if info['app_doc'].app_email:
57        info['email'] = info['app_doc'].app_email
58    else:
[1281]59        info['email'] = info['per_doc'].email
60
61    msg="""
[1268]62Your SRP Member Details
63-----------------------
64
[1223]65Fullname: %s
66Student Id: %s
67Matriculation Number: %s
[2885]68Registration Number: %s
[1541]69Registration Status: %s
[1254]70Email Address in Application Data: %s
71Email Address in Personal Data: %s
[1223]72Date of Birth: %s
[1316]73Password: '%s'
[1223]74
75"""
76
[1281]77    info['message'] = msg % (
78        student.Title(),
79        student_id,
80        info['clear_doc'].matric_no,
81        info['app_doc'].jamb_reg_no,
[1541]82        info['review_state'],
[1281]83        info['app_doc'].app_email,
84        info['per_doc'].email,
85        info['clear_doc'].birthday,
86        info['password']
87        )
88else:
[1316]89
[1281]90    info['student'] = student
91    info['id'] = student_id
92    info['review_state'] = wf.getInfoFor(student,'review_state',None)
93    info['password'] = context.waeup_tool.getCredential(student_id)
[1448]94    info['email'] = 'N/A'
[1223]95
[1281]96    msg="""
97Your SRP Member Details
98-----------------------
99
100Fullname: %s
101Student Id: %s
102Password: %s
103
104"""
105
106    info['message'] = msg % (
[1448]107        'N/A',
[1281]108        student_id,
109        info['password']
110        )
111
[1316]112
113
114
115
[1220]116return info
Note: See TracBrowser for help on using the repository browser.