## Script (Python) "getLevelInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=student=None ##title= ## # $Id: getLevelInfo.py 2609 2007-11-09 15:38:22Z joachim $ """ return Info about the Faculties """ request = context.REQUEST wf = context.portal_workflow mtool = context.portal_membership academics_path = "%s/campus/academics" % context.portal_url() path_info = request.get('PATH_INFO').split('/') try: i = int(path_info[-1]) p = 0 except: p = 1 info = {} pt = request.get('PATH_INFO').split('/') dep_id = pt[-(3+p)] cert_id = pt[-(2+p)] level_id = pt[-(1+p)] info['action'] = "%s" % context.absolute_url() info['choosen_ids'] = request.get('ids',[]) info['doc'] = context.getContent() # brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1] # cp = brain.getPath() # info['container_path'] = cp info['dep_id'] = dep_id info['cert_id'] = cert_id # res = context.portal_catalog(meta_type="CertificateCourse", container_path="%s/%s" % (cp,level_id)) # first = [] # second = [] # for r in res: # row = {} # ro = r.getObject() # rd = ro.getContent() # course_id = r.getId # row = context.getCourseInfo(course_id) # row['id'] = course_id # # row['title'] = rd.Title() # # row['semester'] = rd.semester # row['core'] = rd.core_or_elective # row['url'] = ro.absolute_url() # row['review_state'] = wf.getInfoFor(ro,'review_state','None') # editable = row['is_editable'] = mtool.checkPermission('Modify portal content', ro) # if editable: # row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path, # row['faculty'], # row['department'], # course_id) # if row['semester'] == 1: # first.append(row) # else: # second.append(row) first = [] second = [] for course_id,course in context.objectItems(): row = {} # ro = r.getObject() course_doc = course.getContent() # course_id = r.getId row = context.getCourseInfo(course_id) row['id'] = course_id # row['title'] = course_doc.Title() # row['semester'] = course_doc.semester row['core'] = course_doc.core_or_elective row['url'] = course.absolute_url() row['review_state'] = wf.getInfoFor(course,'review_state','None') editable = row['is_editable'] = mtool.checkPermission('Modify portal content', course) if editable: row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path, row['faculty'], row['department'], course_id) if row['semester'] == 1: first.append(row) else: second.append(row) first.sort() second.sort() info['first'] = first info['second'] = second return info