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 | """ |
---|
12 | return Info about the current Student |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('Student.Member.Info') |
---|
16 | |
---|
17 | request = context.REQUEST |
---|
18 | mtool = context.portal_membership |
---|
19 | wf = context.portal_workflow |
---|
20 | member = mtool.getAuthenticatedMember() |
---|
21 | member_id = str(member) |
---|
22 | path_info = request.get('PATH_INFO').split('/') |
---|
23 | ##from Products.zdb import set_trace |
---|
24 | ##set_trace() |
---|
25 | if mtool.isAnonymousUser(): |
---|
26 | return None |
---|
27 | info = {} |
---|
28 | requested_id = context.getStudentId() |
---|
29 | if requested_id and not context.isStaff() and member_id != requested_id: |
---|
30 | logger.info('"%s", "accessed personal object of", "%s"' % (member_id,requested_id)) |
---|
31 | student_id = requested_id |
---|
32 | elif context.isStaff(): |
---|
33 | student_id = requested_id |
---|
34 | else: |
---|
35 | student_id = member_id |
---|
36 | |
---|
37 | |
---|
38 | students_object = context.portal_url.getPortalObject().campus.students |
---|
39 | student = getattr(students_object, student_id) |
---|
40 | |
---|
41 | if hasattr(student,"application"): |
---|
42 | |
---|
43 | info['student'] = student |
---|
44 | info['id'] = student_id |
---|
45 | info['review_state'] = wf.getInfoFor(student,'review_state',None) |
---|
46 | info['per'] = student.personal |
---|
47 | info['app'] = student.application |
---|
48 | info['per_doc'] = student.personal.getContent() |
---|
49 | info['app_doc'] = student.application.getContent() |
---|
50 | info['clear_doc'] = student.clearance.getContent() |
---|
51 | info['password'] = context.waeup_tool.getCredential(student_id) |
---|
52 | |
---|
53 | if info['per_doc'].email: |
---|
54 | info['email'] = info['per_doc'].email |
---|
55 | else: |
---|
56 | info['email'] = info['app_doc'].app_email |
---|
57 | |
---|
58 | msg=""" |
---|
59 | Your SRP Member Details |
---|
60 | ----------------------- |
---|
61 | |
---|
62 | Fullname: %s |
---|
63 | Student Id: %s |
---|
64 | Matriculation Number: %s |
---|
65 | JAMB Registration Number: %s |
---|
66 | Email Address in Application Data: %s |
---|
67 | Email Address in Personal Data: %s |
---|
68 | Date of Birth: %s |
---|
69 | Password: %s |
---|
70 | |
---|
71 | """ |
---|
72 | |
---|
73 | info['message'] = msg % ( |
---|
74 | student.Title(), |
---|
75 | student_id, |
---|
76 | info['clear_doc'].matric_no, |
---|
77 | info['app_doc'].jamb_reg_no, |
---|
78 | info['app_doc'].app_email, |
---|
79 | info['per_doc'].email, |
---|
80 | info['clear_doc'].birthday, |
---|
81 | info['password'] |
---|
82 | ) |
---|
83 | else: |
---|
84 | |
---|
85 | info['student'] = student |
---|
86 | info['id'] = student_id |
---|
87 | info['review_state'] = wf.getInfoFor(student,'review_state',None) |
---|
88 | info['password'] = context.waeup_tool.getCredential(student_id) |
---|
89 | info['email'] = 'na' |
---|
90 | |
---|
91 | msg=""" |
---|
92 | Your SRP Member Details |
---|
93 | ----------------------- |
---|
94 | |
---|
95 | Fullname: %s |
---|
96 | Student Id: %s |
---|
97 | Password: %s |
---|
98 | |
---|
99 | """ |
---|
100 | |
---|
101 | info['message'] = msg % ( |
---|
102 | 'na', |
---|
103 | student_id, |
---|
104 | info['password'] |
---|
105 | ) |
---|
106 | |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | |
---|
111 | return info |
---|