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

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

fix #457 traceback

File size: 2.9 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('/')
23if mtool.isAnonymousUser():
24    return None
25info = {}
26requested_id = context.getStudentId()
27if 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
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)
39
40if hasattr(student,"application") and hasattr(student,"personal") and hasattr(student,"clearance"):
41    info['student'] = student
42    info['id'] = student_id
43    info['review_state'] = context.getStudentReviewState()
44    info['per'] = getattr(student,'personal',None)
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
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:
59        info['email'] = info['per_doc'].email
60
61    msg="""
62Your SRP Member Details
63-----------------------
64
65Fullname: %s
66Student Id: %s
67Matriculation Number: %s
68Registration Number: %s
69Registration Status: %s
70Email Address in Application Data: %s
71Email Address in Personal Data: %s
72Date of Birth: %s
73Password: '%s'
74
75"""
76
77    info['message'] = msg % (
78        student.Title(),
79        student_id,
80        info['clear_doc'].matric_no,
81        info['app_doc'].jamb_reg_no,
82        info['review_state'],
83        info['app_doc'].app_email,
84        info['per_doc'].email,
85        info['clear_doc'].birthday,
86        info['password']
87        )
88else:
89
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)
94    info['email'] = 'N/A'
95
96    msg="""
97Your SRP Member Details
98-----------------------
99
100Fullname: %s
101Student Id: %s
102Password: %s
103
104"""
105
106    info['message'] = msg % (
107        'N/A',
108        student_id,
109        info['password']
110        )
111
112
113
114
115
116return info
Note: See TracBrowser for help on using the repository browser.