source: WAeUP_SRP/base/skins/waeup_academics/getCoursesInfo.py @ 3076

Last change on this file since 3076 was 2633, checked in by joachim, 17 years ago

sort courses for courses_view, eine eigene headline pro Semester erfordert erhebliche Gehirnakrobatik in Kombination mit dem Batch view.

  • Property svn:keywords set to Id
File size: 1.6 KB
RevLine 
[845]1## Script (Python) "getCoursesInfo"
[556]2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=student=None
8##title=
9##
[805]10# $Id: getCoursesInfo.py 2633 2007-11-12 18:46:13Z joachim $
[556]11"""
12return Info about the Faculties
13"""
[1366]14def cmpsemester(a,b):
15    if a.semester == b.semester:
16        return 0
17    if a.semester > b.semester:
18        return 1
19    return -1
20   
21
22
[556]23request = context.REQUEST
24
25wf = context.portal_workflow
[603]26path_info = request.get('PATH_INFO').split('/')
[556]27mtool = context.portal_membership
28
29info = {}
[573]30#dep_id = request.get('PATH_TRANSLATED').split('/')[-2]
31dep_id = context.aq_parent.getId()
32info['action'] = "%s" % context.absolute_url()
[556]33info['choosen_ids'] = request.get('ids',[])
34info['doc'] = context.getContent()
[566]35res = context.portal_catalog(meta_type="Department",id = dep_id)
36info['courses'] = []
37if not res:
38    return info
39brain = res[-1]
[556]40cp = brain.getPath()
41info['container_path'] = cp
42info['dep_id'] = dep_id
43
[1366]44res = context.courses_catalog(department=dep_id)
45items = [ brain for brain in res]
46items.sort(cmpsemester)
47rows = []
48for r in items:
49    row = {}
50    code = getattr(r,'code',None)
51    if code is None:
52        continue
53    ro = getattr(context,code)
54    row['id'] = code
55    row['title'] = r['title']
56    row['semester'] = r['semester']
57    row['url'] = "%s/%s" % (context.absolute_url(),code)
58    row['review_state'] = wf.getInfoFor(ro,'review_state','None')
59    row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
60    rows.append(row)
[2633]61rows.sort(cmp=lambda x,y: cmp("%(semester)s%(id)s" % x,
62                              "%(semester)s%(id)s" % y))
[1366]63info['courses'] = rows
[556]64return info
Note: See TracBrowser for help on using the repository browser.