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 1104 2006-12-20 14:32:51Z 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'])) |
---|
40 | to_modify.append((r.bed,r.student,info['student_status'])) |
---|
41 | |
---|
42 | for former_bed, student, status in to_modify: |
---|
43 | beds.modifyRecord(bed=former_bed,student='') |
---|
44 | code,bed = beds.searchAndReserveBed(student,status) |
---|
45 | if code > 0: |
---|
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') |
---|
52 | info['acco_doc'].edit(mapping=d) |
---|
53 | list.append("Student %s new bed %s assigned code = %s" % (r.student, |
---|
54 | bed, |
---|
55 | code)) |
---|
56 | return "\r".join(list) |
---|