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 | 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 | |
---|
36 | |
---|
37 | students_object = context.portal_url.getPortalObject().campus.students |
---|
38 | student = getattr(students_object, student_id) |
---|
39 | |
---|
40 | if hasattr(student,"application"): |
---|
41 | |
---|
42 | info['student'] = student |
---|
43 | info['id'] = student_id |
---|
44 | info['review_state'] = context.getStudentReviewState() |
---|
45 | info['per'] = student.personal |
---|
46 | info['app'] = student.application |
---|
47 | info['per_doc'] = student.personal.getContent() |
---|
48 | info['app_doc'] = student.application.getContent() |
---|
49 | info['clear_doc'] = student.clearance.getContent() |
---|
50 | info['password'] = context.waeup_tool.getCredential(student_id) |
---|
51 | |
---|
52 | # if info['per_doc'].email: |
---|
53 | # info['email'] = info['per_doc'].email |
---|
54 | # else: |
---|
55 | # info['email'] = info['app_doc'].app_email |
---|
56 | |
---|
57 | if info['app_doc'].app_email: |
---|
58 | info['email'] = info['app_doc'].app_email |
---|
59 | else: |
---|
60 | info['email'] = info['per_doc'].email |
---|
61 | |
---|
62 | msg=""" |
---|
63 | Your SRP Member Details |
---|
64 | ----------------------- |
---|
65 | |
---|
66 | Fullname: %s |
---|
67 | Student Id: %s |
---|
68 | Matriculation Number: %s |
---|
69 | Registration Number: %s |
---|
70 | Registration Status: %s |
---|
71 | Email Address in Application Data: %s |
---|
72 | Email Address in Personal Data: %s |
---|
73 | Date of Birth: %s |
---|
74 | Password: '%s' |
---|
75 | |
---|
76 | """ |
---|
77 | |
---|
78 | info['message'] = msg % ( |
---|
79 | student.Title(), |
---|
80 | student_id, |
---|
81 | info['clear_doc'].matric_no, |
---|
82 | info['app_doc'].jamb_reg_no, |
---|
83 | info['review_state'], |
---|
84 | info['app_doc'].app_email, |
---|
85 | info['per_doc'].email, |
---|
86 | info['clear_doc'].birthday, |
---|
87 | info['password'] |
---|
88 | ) |
---|
89 | else: |
---|
90 | |
---|
91 | info['student'] = student |
---|
92 | info['id'] = student_id |
---|
93 | info['review_state'] = wf.getInfoFor(student,'review_state',None) |
---|
94 | info['password'] = context.waeup_tool.getCredential(student_id) |
---|
95 | info['email'] = 'N/A' |
---|
96 | |
---|
97 | msg=""" |
---|
98 | Your SRP Member Details |
---|
99 | ----------------------- |
---|
100 | |
---|
101 | Fullname: %s |
---|
102 | Student Id: %s |
---|
103 | Password: %s |
---|
104 | |
---|
105 | """ |
---|
106 | |
---|
107 | info['message'] = msg % ( |
---|
108 | 'N/A', |
---|
109 | student_id, |
---|
110 | info['password'] |
---|
111 | ) |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | return info |
---|