## 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 current Student """ request = context.REQUEST form = request.form fget = form.get wf = context.portal_workflow mtool = context.portal_membership member = mtool.getAuthenticatedMember() path_info = request.get('PATH_INFO').split('/') roles = member.getRoles() info = {} info['is_manager'] = context.isManager info['is_student'] = context.isStudent() member_id = str(member) if student is None: if context.isManager(): if context.portal_type == 'Student': student_id = context.getId() else: student_id = context.aq_parent.getId() else: student_id = member_id else: student_id = student.getId() res = context.portal_catalog(id = student_id,portal_type='Student') if not res or len(res) > 1: return None brain = res[-1] student = brain.getObject() student_path = brain.getPath() info['review_state'] = wf.getInfoFor(student,'review_state','keiner') info['student'] = student info['id'] = student.getId() info['url'] = student.absolute_url() info['student_doc'] = student.getContent() info['app'] = student.application info['app_doc'] = student.application.getContent() info['per'] = student.personal info['per_doc'] = student.personal.getContent() info['sex'] = 'male' if info['per_doc'].sex: info['sex'] = 'female' res = context.portal_catalog(container_path=student_path, portal_type='StudentAccommodation') if res: acco = res[0].getObject() info['acco'] = acco info['acco_doc'] = acco.getContent() else: info['acco'] = None items = [] s_edit_links = {'StudentApplication': 'student_edit', 'StudentAccommodation': '', 'StudentPersonal': '', } s_view_links = {'StudentApplication': 'application_view', 'StudentAccommodation': 'accommodation_view', 'StudentPersonal': 'personal_view', } sos = context.portal_catalog(container_path=student_path) for so in sos: row = {} soo = so.getObject() sod = soo.getContent() row['id'] = soo.getId() row['title'] = sod.Title() row['url'] = soo.absolute_url() row['type'] = so.portal_type row['is_editable'] = mtool.checkPermission('Modify portal content', soo) sv_link = s_view_links.get(so.portal_type,None) row['s_view_link'] = None if sv_link: row['s_view_link'] = "%s/%s" % (student.absolute_url(),sv_link) se_link = s_edit_links.get(so.portal_type,None) row['s_edit_link'] = None if se_link: row['s_edit_link'] = "%s/%s" % (student.absolute_url(),se_link) row['review_state'] = so.review_state row['display'] = so.review_state in ('opened','closed') items.append(row) info['items'] = items return info