Changeset 1135


Ignore:
Timestamp:
22 Dec 2006, 17:03:35 (18 years ago)
Author:
joachim
Message:

New function and tab to change bed

Location:
WAeUP_SRP/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/profiles/default/types/StudentAccommodation.xml

    r1018 r1135  
    3838  <permission value="Modify portal content"/>
    3939 </action>
     40 <action title="Change Bed" action_id="change_bed" category="object"
     41    condition_expr="" url_expr="string:${object_url}/change_bed"
     42    visible="True">
     43  <permission value="Modify portal content"/>
     44 </action>
    4045</object>
  • WAeUP_SRP/trunk/skins/waeup_accommodation/change_bed.py

    r1117 r1135  
    1010# $Id$
    1111"""
    12 return Info about the current Student
     12relocate to a new bed if allocated bed is wrong
    1313"""
    1414import logging
    15 logger = logging.getLogger('Student.Clearance.Info')
     15logger = logging.getLogger('Student.Accommodation.change_bed')
    1616
    1717request = context.REQUEST
     18redirect = request.RESPONSE.redirect
    1819mtool = context.portal_membership
    1920wf = context.portal_workflow
     
    2425if mtool.isAnonymousUser():
    2526    return None
    26 info = {}
     27students = context.portal_url.getPortalObject().campus.students
    2728beds = context.portal_accommodation
    2829studs = context.students_catalog
     30student_id = context.getStudentId()
     31
     32if student_id is not None:
     33    logger.info('"%s", "requests bed_change for", "%s"' % (member_id,student_id))
     34    info = context.getAccommodationInfo(student_id)
     35    res = beds(student=student_id)
     36    if len(res) == 0:
     37        logger.info('"%s", "no bed found"' % (student_id))
     38        redirect("%s/%s" % (students.absolute_url(),student_id))
     39    allocated_bed = res[0]
     40    status = info['student_status']
     41    student = student_id
     42    if allocated_bed.bed_type == status:
     43        logger.info('"%s", "correct bed allocated","%s"' % (student_id,status))
     44        redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
     45    logger.info('"%s", "change bed", "%s/%s"' % (student_id,allocated_bed.bed_type,status))
     46    beds.modifyRecord(bed=allocated_bed.bed,student='')
     47    code,bed = beds.searchAndReserveBed(student_id,status)
     48    if code > 0:
     49        #from Products.zdb import set_trace; set_trace()
     50        d = {}
     51        d['bed'] = bed
     52        d['student_status'] = status
     53        acco_info = context.waeup_tool.getAccommodationInfo(bed)
     54        d['acco_maint_code'] = acco_info.get('maintenance_code')
     55        d['acco_maint_fee'] = acco_info.get('maintenance_fee')
     56        acco_doc = info['acco_doc']
     57        acco_doc.edit(mapping=d)
     58        redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
     59    logger.info('"%s", "new bed allocation failed","%s"' % (student_id,code))
     60    redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
     61       
     62info = {}
    2963records = [r for r in beds() if  r.student]
    3064list = []
Note: See TracChangeset for help on using the changeset viewer.