[1313] | 1 | ## Script (Python) "getClearanceInfo" |
---|
| 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: getTransferInfo.py 1333 2007-01-21 00:20:02Z henrik $ |
---|
| 11 | """ |
---|
| 12 | return Info about the current Student |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
| 15 | logger = logging.getLogger('Student.Clearance.Info') |
---|
| 16 | from DateTime import DateTime |
---|
| 17 | |
---|
| 18 | request = context.REQUEST |
---|
| 19 | mtool = context.portal_membership |
---|
| 20 | wf = context.portal_workflow |
---|
| 21 | member = mtool.getAuthenticatedMember() |
---|
| 22 | member_id = str(member) |
---|
| 23 | path_info = request.get('PATH_INFO').split('/') |
---|
| 24 | |
---|
| 25 | if mtool.isAnonymousUser(): |
---|
| 26 | return None |
---|
| 27 | info = {} |
---|
| 28 | #from Products.zdb import set_trace |
---|
| 29 | #set_trace() |
---|
| 30 | requested_id = context.getStudentId() |
---|
| 31 | if requested_id and not context.isStaff() and member_id != requested_id: |
---|
| 32 | logger.info('"%s", "tried to access", "%s"' % (member_id,requested_id)) |
---|
| 33 | return None |
---|
| 34 | elif context.isStaff(): |
---|
| 35 | student_id = requested_id |
---|
| 36 | else: |
---|
| 37 | student_id = member_id |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | students_object = context.portal_url.getPortalObject().campus.students |
---|
[1331] | 41 | |
---|
| 42 | student = getattr(students_object,student_id) |
---|
| 43 | payments = getattr(student,'payments').objectIds() |
---|
| 44 | info['payed'] = False |
---|
| 45 | for payment in payments: |
---|
| 46 | if payment.startswith('transfer'): |
---|
| 47 | info['payed'] = True |
---|
| 48 | payments_obj = getattr(student,'payments') |
---|
| 49 | payment_obj = getattr(payments_obj,payment) |
---|
| 50 | info['pin'] = payment_obj.getContent().order_id |
---|
| 51 | break |
---|
[1332] | 52 | |
---|
[1331] | 53 | |
---|
[1313] | 54 | #student = getattr(students_object, student_id) |
---|
| 55 | res = context.students_catalog(id = student_id) |
---|
| 56 | if len(res) != 1: |
---|
| 57 | return None |
---|
| 58 | sbrain = res[0] |
---|
| 59 | info['id'] = student_id |
---|
| 60 | info['student'] = context.getFormattedStudentEntry(sbrain) |
---|
| 61 | info['entry_mode'] = sbrain.entry_mode |
---|
[1317] | 62 | results = context.results_import(matric_no=sbrain.matric_no) |
---|
[1313] | 63 | taken = [] |
---|
| 64 | if len(results) > 0: |
---|
| 65 | for r in results: |
---|
[1331] | 66 | taken.append(r) |
---|
[1313] | 67 | info['taken'] = taken |
---|
[1333] | 68 | |
---|
| 69 | # for testing of transfer forms |
---|
| 70 | info['payed'] = True |
---|
| 71 | info['pin'] = 'CLR-1-0123456789' |
---|
| 72 | |
---|
| 73 | |
---|
[1313] | 74 | return info |
---|