source: WAeUP_SRP/trunk/skins/waeup_student/getLecturerCoursesInfo.py @ 17952

Last change on this file since 17952 was 3753, checked in by Henrik Bettermann, 16 years ago

allow more than one lecturer in course

File size: 1.7 KB
RevLine 
[3611]1## Script (Python) "getLecturerCoursesInfo"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: getCoursesInfo.py 3482 2008-05-01 05:54:53Z henrik $
11"""
12return Info about the Courses
13"""
14
[3753]15#from Products.AdvancedQuery import Eq, Between, Le,In
[3611]16mtool = context.portal_membership
17member = mtool.getAuthenticatedMember()
18lec_id = member_id = str(member)
19if mtool.isAnonymousUser():
20    return None
21
22
23def cmpsemester(a,b):
24    if a.semester == b.semester:
25        return 0
26    if a.semester > b.semester:
27        return 1
28    return -1
29
30request = context.REQUEST
31
32path_info = request.get('PATH_INFO').split('/')
33
34
35info = {}
36info['lec_id'] = lec_id
37
38res = context.courses_catalog(lecturer=lec_id)
[3753]39#query = Eq('lecturer',lec_id)
40#res = context.courses_catalog.evalAdvancedQuery(query)   #works both with lecturer as TextIndex
[3611]41items = [ brain for brain in res]
42items.sort(cmpsemester)
43rows = []
44for r in items:
45    row = {}
46    code = getattr(r,'code',None)
47    if code is None:
48        continue
49    #ro = getattr(context,code)
50    row['id'] = code
51    row['title'] = r['title']
52    row['semester'] = r['semester']
53    row['course_url'] = "%s/campus/academics/%s/%s/courses/%s" % (context.portal_url(),r['faculty'],r['department'],code)
54    row['list_url'] = "%s/getLecturerCourseResults?course_id=%s" % (context.portal_url(),code)
55    #row['review_state'] = wf.getInfoFor(ro,'review_state','None')
56    #row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
57    rows.append(row)
58rows.sort(cmp=lambda x,y: cmp("%(semester)s%(id)s" % x,
59                              "%(semester)s%(id)s" % y))
60info['courses'] = rows
61return info
Note: See TracBrowser for help on using the repository browser.