[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 | """ |
---|
| 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: |
---|
[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] | 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) |
---|
[1223] | 39 | |
---|
[1281] | 40 | if hasattr(student,"application"): |
---|
[1254] | 41 | |
---|
[1281] | 42 | info['student'] = student |
---|
| 43 | info['id'] = student_id |
---|
[1871] | 44 | info['review_state'] = context.getStudentReviewState() |
---|
[1281] | 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 | msg=""" |
---|
[1268] | 58 | Your SRP Member Details |
---|
| 59 | ----------------------- |
---|
| 60 | |
---|
[1223] | 61 | Fullname: %s |
---|
| 62 | Student Id: %s |
---|
| 63 | Matriculation Number: %s |
---|
| 64 | JAMB Registration Number: %s |
---|
[1541] | 65 | Registration Status: %s |
---|
[1254] | 66 | Email Address in Application Data: %s |
---|
| 67 | Email Address in Personal Data: %s |
---|
[1223] | 68 | Date of Birth: %s |
---|
[1316] | 69 | Password: '%s' |
---|
[1223] | 70 | |
---|
| 71 | """ |
---|
| 72 | |
---|
[1281] | 73 | info['message'] = msg % ( |
---|
| 74 | student.Title(), |
---|
| 75 | student_id, |
---|
| 76 | info['clear_doc'].matric_no, |
---|
| 77 | info['app_doc'].jamb_reg_no, |
---|
[1541] | 78 | info['review_state'], |
---|
[1281] | 79 | info['app_doc'].app_email, |
---|
| 80 | info['per_doc'].email, |
---|
| 81 | info['clear_doc'].birthday, |
---|
| 82 | info['password'] |
---|
| 83 | ) |
---|
| 84 | else: |
---|
[1316] | 85 | |
---|
[1281] | 86 | info['student'] = student |
---|
| 87 | info['id'] = student_id |
---|
| 88 | info['review_state'] = wf.getInfoFor(student,'review_state',None) |
---|
| 89 | info['password'] = context.waeup_tool.getCredential(student_id) |
---|
[1448] | 90 | info['email'] = 'N/A' |
---|
[1223] | 91 | |
---|
[1281] | 92 | msg=""" |
---|
| 93 | Your SRP Member Details |
---|
| 94 | ----------------------- |
---|
| 95 | |
---|
| 96 | Fullname: %s |
---|
| 97 | Student Id: %s |
---|
| 98 | Password: %s |
---|
| 99 | |
---|
| 100 | """ |
---|
| 101 | |
---|
| 102 | info['message'] = msg % ( |
---|
[1448] | 103 | 'N/A', |
---|
[1281] | 104 | student_id, |
---|
| 105 | info['password'] |
---|
| 106 | ) |
---|
| 107 | |
---|
[1316] | 108 | |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | |
---|
[1220] | 112 | return info |
---|