## Script (Python) "getLecturerCoursesInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: getCoursesInfo.py 3482 2008-05-01 05:54:53Z henrik $ """ return Info about the Courses """ mtool = context.portal_membership member = mtool.getAuthenticatedMember() lec_id = member_id = str(member) if mtool.isAnonymousUser(): return None def cmpsemester(a,b): if a.semester == b.semester: return 0 if a.semester > b.semester: return 1 return -1 request = context.REQUEST path_info = request.get('PATH_INFO').split('/') info = {} info['lec_id'] = lec_id res = context.courses_catalog(lecturer=lec_id) items = [ brain for brain in res] items.sort(cmpsemester) rows = [] for r in items: row = {} code = getattr(r,'code',None) if code is None: continue #ro = getattr(context,code) row['id'] = code row['title'] = r['title'] row['semester'] = r['semester'] row['course_url'] = "%s/campus/academics/%s/%s/courses/%s" % (context.portal_url(),r['faculty'],r['department'],code) row['list_url'] = "%s/getLecturerCourseResults?course_id=%s" % (context.portal_url(),code) #row['review_state'] = wf.getInfoFor(ro,'review_state','None') #row['is_editable'] = mtool.checkPermission('Modify portal content', ro) rows.append(row) rows.sort(cmp=lambda x,y: cmp("%(semester)s%(id)s" % x, "%(semester)s%(id)s" % y)) info['courses'] = rows return info