[1104] | 1 | ## Script (Python) "getStudentInfo" |
---|
| 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: change_bed.py 1117 2006-12-21 16:19:39Z joachim $ |
---|
| 11 | """ |
---|
| 12 | return Info about the current Student |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
| 15 | logger = logging.getLogger('Student.Clearance.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 | |
---|
| 24 | if mtool.isAnonymousUser(): |
---|
| 25 | return None |
---|
| 26 | info = {} |
---|
| 27 | beds = context.portal_accommodation |
---|
| 28 | studs = context.students_catalog |
---|
| 29 | records = [r for r in beds() if r.student] |
---|
| 30 | list = [] |
---|
| 31 | to_modify = [] |
---|
| 32 | for r in records: |
---|
| 33 | info = context.getAccommodationInfo(r.student) |
---|
| 34 | if r.bed_type == info['student_status']: |
---|
| 35 | list.append("Student %s bed_type %s ok" % (r.student,r.bed_type)) |
---|
| 36 | continue |
---|
| 37 | list.append("Student %s bed_type %s != %s" % (r.student, |
---|
| 38 | r.bed_type, |
---|
| 39 | info['student_status'])) |
---|
[1117] | 40 | to_modify.append((r.bed,r.student,info['student_status'],info['acco_doc'])) |
---|
| 41 | for former_bed, student, status,acco_doc in to_modify: |
---|
[1104] | 42 | beds.modifyRecord(bed=former_bed,student='') |
---|
| 43 | code,bed = beds.searchAndReserveBed(student,status) |
---|
| 44 | if code > 0: |
---|
[1117] | 45 | #from Products.zdb import set_trace; set_trace() |
---|
[1104] | 46 | d = {} |
---|
| 47 | d['bed'] = bed |
---|
| 48 | d['student_status'] = status |
---|
| 49 | acco_info = context.waeup_tool.getAccommodationInfo(bed) |
---|
| 50 | d['acco_maint_code'] = acco_info.get('maintenance_code') |
---|
| 51 | d['acco_maint_fee'] = acco_info.get('maintenance_fee') |
---|
[1117] | 52 | acco_doc.edit(mapping=d) |
---|
| 53 | list.append("Student %s new bed %s assigned code = %s" % (student, |
---|
[1104] | 54 | bed, |
---|
| 55 | code)) |
---|
| 56 | return "\r".join(list) |
---|