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