## Script (Python) "cpsdocument_edit" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##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 info = {} wf = context.portal_workflow catalog = context.portal_catalog lt = context.portal_layouts pr = context.portal_registration path_info = request.get('PATH_INFO').split('/') is_manager = context.isManager validate = request.has_key("cpsdocument_edit_button") items = [] default = {'search_mode': 'course', 'review_state': 'unchecked', 'search_string': '' } rend,psm,ds = lt.renderLayout(layout_id= 'academics_search', schema_id= 'academics_search', context=context, mapping=validate and request, ob=default, layout_mode='edit', formaction="searchAcademics" ) if psm == '': return context.academics_search_view(rendered = rend, psm = psm, #psm = "%s, %s" % (psm,ds), objects = items, is_manager = is_manager, ) what = ds.get('search_mode') state = ds.get('review_state') term = ds.get('search_string') if state == " ----- ": state = '' if not term and what in ('student_edit','jamb_reg_no','name','matric_no'): return context.academics_search_view(rendered = rend, psm = "You must specify a search string", #psm = "%s, %s" % (psm,ds), objects = items, is_manager = is_manager, ) onlyreview = state and what == "review_state" items = [] res = [] portal_type_query = {'query':['Department','Course','CertificateCourse']} if onlyreview: res = catalog(portal_type=portal_type_query, review_state=state) elif what == "student_id": res = catalog(portal_type='Student', id = term.strip()) elif what == "jamb_reg_no": res = catalog(portal_type='StudentApplication', SearchableText="%s*" % term.strip().lower()) elif what == "matric_no": res = catalog(portal_type='StudentClearance', SearchableText="%s*" % term.strip().lower()) elif what == "name": res = catalog(portal_type=portal_type_query, SearchableText="%s*" % term.strip()) if res: for r in res: row = {} if r.portal_type in ("StudentApplication","StudentPersonal"): items.append(r.getObject().aq_parent) else: items.append(r.getObject()) objects = [] if items: for item in items: objects.append(context.getStudentInfo(item)) return context.academics_search_view(rendered = rend, psm = "%d matching objects found" % len(items), #psm = "%s, %s" % (psm,ds), objects = objects, is_manager = is_manager, )