source: WAeUP_SRP/trunk/skins/waeup_accommodation/change_bed.py @ 1107

Last change on this file since 1107 was 1104, checked in by joachim, 18 years ago

change beds for ekenhua campusstudents.

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
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"""
12return Info about the current Student
13"""
14import logging
15logger = logging.getLogger('Student.Clearance.Info')
16
17request = context.REQUEST
18mtool = context.portal_membership
19wf = context.portal_workflow
20member = mtool.getAuthenticatedMember()
21member_id = str(member)
22path_info = request.get('PATH_INFO').split('/')
23
24if mtool.isAnonymousUser():
25    return None
26info = {}
27beds = context.portal_accommodation
28studs = context.students_catalog
29records = [r for r in beds() if  r.student]
30list = []
31to_modify = []
32for 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   
42for 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))
56return "\r".join(list)
Note: See TracBrowser for help on using the repository browser.