## Script (Python) "cpsdocument_edit" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=student=None ##title= ## # $Id: student_edit.py 486 2006-09-06 10:09:39Z joachim $ """ return Info about the Faculties """ request = context.REQUEST wf = context.portal_workflow path_info = request.get('PATH_INFO').split('/') mtool = context.portal_membership pa = context.portal_accommodation info = {} #dep_id = request.get('PATH_TRANSLATED').split('/')[-2] dep_id = context.aq_parent.getId() info['is_manager'] = context.isManager() info['is_student'] = context.isStudent() info['action'] = "%s" % context.absolute_url() info['choosen_ids'] = request.get('ids',[]) info['doc'] = context.getContent() bed_types = pa.uniqueValuesFor('bed_type') bt_list = [] bt_names = context.getBedTypeNames() reserved = pa.uniqueValuesFor('student') for bt in bed_types: total = len(pa(bed_type=bt,hall=context.getId())) free = len(pa.searchResults({'bed_type': bt, 'student':reserved, 'hall': context.getId()})) bt_list.append({'name': bt_names[bt], 'total': total, 'reserved': free, }) info['bed_types'] = bt_list res_list = [] students_rpath = context.portal_catalog(meta_type = "StudentsFolder")[-1].relative_path students_url = "%s/%s" % (context.portal_url(),students_rpath) if reserved > 1: for st in reserved: if st: res = pa(hall=context.getId(),student=st) if res: res_list.append({'student': st, 'student_url': '%s/%s' % (students_url,st), 'bed': context.formatBed(res[0].bed) }) info['reserved'] = res_list return info