source: WAeUP_SRP/base/skins/waeup_student/getLecturerCoursesInfo.py @ 3681

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

implement lecturer module (for demo purposes only)

File size: 1.5 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
15mtool = context.portal_membership
16member = mtool.getAuthenticatedMember()
17lec_id = member_id = str(member)
18if mtool.isAnonymousUser():
19    return None
20
21
22def cmpsemester(a,b):
23    if a.semester == b.semester:
24        return 0
25    if a.semester > b.semester:
26        return 1
27    return -1
28
29request = context.REQUEST
30
31path_info = request.get('PATH_INFO').split('/')
32
33
34info = {}
35info['lec_id'] = lec_id
36
37res = context.courses_catalog(lecturer=lec_id)
38items = [ brain for brain in res]
39items.sort(cmpsemester)
40rows = []
41for r in items:
42    row = {}
43    code = getattr(r,'code',None)
44    if code is None:
45        continue
46    #ro = getattr(context,code)
47    row['id'] = code
48    row['title'] = r['title']
49    row['semester'] = r['semester']
50    row['course_url'] = "%s/campus/academics/%s/%s/courses/%s" % (context.portal_url(),r['faculty'],r['department'],code)
51    row['list_url'] = "%s/getLecturerCourseResults?course_id=%s" % (context.portal_url(),code)
52    #row['review_state'] = wf.getInfoFor(ro,'review_state','None')
53    #row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
54    rows.append(row)
55rows.sort(cmp=lambda x,y: cmp("%(semester)s%(id)s" % x,
56                              "%(semester)s%(id)s" % y))
57info['courses'] = rows
58return info
Note: See TracBrowser for help on using the repository browser.