[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('/') |
---|
[3458] | 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 | info = context.waeup_tool.getAccessInfo(context) |
---|
| 37 | student_id = info['student_id'] |
---|
| 38 | if student_id is None: |
---|
[3858] | 39 | return 'You are not allowed to access this information!' |
---|
[1220] | 40 | |
---|
| 41 | students_object = context.portal_url.getPortalObject().campus.students |
---|
| 42 | student = getattr(students_object, student_id) |
---|
[1223] | 43 | |
---|
[3458] | 44 | complete_msg=""" |
---|
| 45 | Your SRP Member Details |
---|
| 46 | ----------------------- |
---|
[2504] | 47 | |
---|
[3458] | 48 | Fullname: %(student_name)s |
---|
| 49 | Student Id: %(id)s |
---|
| 50 | Matriculation Number: %(matric_no)s |
---|
| 51 | Registration Number: %(jamb_reg_no)s |
---|
| 52 | Registration Status: %(review_state)s |
---|
| 53 | Email Address in Application Data: %(app_email)s |
---|
| 54 | Email Address in Personal Data: %(per_email)s |
---|
| 55 | Date of Birth: %(birthday)s |
---|
| 56 | Password: '%(password)s' |
---|
[1281] | 57 | |
---|
[3458] | 58 | """ |
---|
| 59 | short_msg=""" |
---|
[1268] | 60 | Your SRP Member Details |
---|
| 61 | ----------------------- |
---|
| 62 | |
---|
[3458] | 63 | Fullname: %(student_name)s |
---|
| 64 | Student Id: %(id)s |
---|
| 65 | Password: %(password)s |
---|
[1223] | 66 | |
---|
| 67 | """ |
---|
[3458] | 68 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
| 69 | if hasattr(student,"application") and hasattr(student,"personal") and hasattr(student,"clearance"): |
---|
| 70 | #info['student'] = student |
---|
| 71 | info['id'] = student_id |
---|
| 72 | info['review_state'] = student_record.review_state |
---|
| 73 | #info['per'] = getattr(student,'personal',None) |
---|
| 74 | #per_doc = info['per_doc'] = student.personal.getContent() |
---|
| 75 | #info['app_doc'] = student.application.getContent() |
---|
| 76 | info['jamb_reg_no'] = student_record.jamb_reg_no |
---|
| 77 | #info['clear_doc'] = student.clearance.getContent() |
---|
| 78 | info['matric_no'] = student_record.matric_no |
---|
| 79 | info['password'] = context.waeup_tool.getCredential(student_id) |
---|
| 80 | info['student_name'] = student_record.name |
---|
| 81 | info['birthday'] = student.clearance.getContent().birthday |
---|
| 82 | app_email = info['app_email'] = student.application.getContent().app_email |
---|
| 83 | per_email = info['per_email'] = student_record.email |
---|
[3859] | 84 | if per_email: |
---|
| 85 | info['email'] = per_email |
---|
| 86 | elif app_email: |
---|
[3458] | 87 | info['email'] = app_email |
---|
| 88 | else: |
---|
[3859] | 89 | info['email'] = '' |
---|
| 90 | |
---|
[3458] | 91 | info['message'] = complete_msg % info |
---|
| 92 | info['with_email'] = bool(info['email']) |
---|
[1281] | 93 | else: |
---|
[3458] | 94 | info['student_name'] = 'N/A' |
---|
[1281] | 95 | info['id'] = student_id |
---|
| 96 | info['review_state'] = wf.getInfoFor(student,'review_state',None) |
---|
| 97 | info['password'] = context.waeup_tool.getCredential(student_id) |
---|
[1448] | 98 | info['email'] = 'N/A' |
---|
[3458] | 99 | info['message'] = short_msg % info |
---|
| 100 | info['with_email'] = False |
---|
[1220] | 101 | return info |
---|