## 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 mtool = context.portal_membership 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': '' } choosen_ids = request.get('ids',[]) 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, choosen_ids = choosen_ids, ) what = ds.get('search_mode') state = ds.get('review_state') term = ds.get('search_string') err = False with_review = state != "all" if not term and not with_review: psm = "You must specify a search string when searching 'all states'." err = True elif '*' in term: psm = "you cannot use the '*' alone" err = True if err: return context.academics_search_view(rendered = rend, psm = psm, #psm = "%s, %s" % (psm,ds), students = items, is_manager = is_manager, choosen_ids = choosen_ids, ) with_review = state != "all" items = [] res = [] portal_type_query = {'query':['Course','CertificateCourse']} onlyreview = with_review and not term if onlyreview: res = catalog(portal_type=portal_type_query, review_state=state) elif what == "course": res = catalog(portal_type='Course', SearchableText="%s*" % term.strip().lower()) elif what == "certificate_course": res = catalog(portal_type='CertificateCourse', SearchableText="%s*" % term.strip().lower()) objects = [] if res: for r in res: row = {} ro = r.getObject() rd = ro.getContent() row['id'] = r.getId row['title'] = rd.Title() row['url'] = ro.absolute_url() row['review_state'] = wf.getInfoFor(ro,'review_state','None') row['is_editable'] = mtool.checkPermission('Modify portal content', ro) objects.append(row) #objects.append(context.getStudentInfo(item)) return context.academics_search_view(rendered = rend, psm = "%d matching objects found" % len(objects), #psm = "%s, %s" % (psm,ds), objects = objects, is_manager = is_manager, choosen_ids = choosen_ids, )