source: WAeUP_SRP/base/skins/waeup_academics/getLevelInfo.py @ 3349

Last change on this file since 3349 was 2614, checked in by Henrik Bettermann, 17 years ago

display semesters seperately: first, second and combined

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1## Script (Python) "getLevelInfo"
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##
10# $Id: getLevelInfo.py 2614 2007-11-09 21:30:03Z henrik $
11"""
12return Info about the Faculties
13"""
14request = context.REQUEST
15
16wf = context.portal_workflow
17mtool = context.portal_membership
18academics_path = "%s/campus/academics" % context.portal_url()
19path_info = request.get('PATH_INFO').split('/')
20try:
21    i = int(path_info[-1])
22    p = 0
23except:
24    p = 1
25info = {}
26pt = request.get('PATH_INFO').split('/')
27
28dep_id = pt[-(3+p)]
29cert_id = pt[-(2+p)]
30level_id = pt[-(1+p)]
31info['action'] = "%s" % context.absolute_url()
32info['choosen_ids'] = request.get('ids',[])
33info['doc'] = context.getContent()
34info['dep_id'] = dep_id
35info['cert_id'] = cert_id
36
37
38first = []
39second = []
40combined = []
41for course_id,course in context.objectItems():
42    row = {}
43    course_doc = course.getContent()
44    row = context.getCourseInfo(course_id)
45    row['id'] = course_id
46    row['core'] = course_doc.core_or_elective
47    row['url'] = course.absolute_url()
48    row['review_state'] = wf.getInfoFor(course,'review_state','None')
49    editable = row['is_editable'] = mtool.checkPermission('Modify portal content', course)
50    if editable:
51        row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path,
52                                                           row['faculty'],
53                                                           row['department'],
54                                                           course_id)
55
56    # The course objects contain strings (old schema) and integers (new schema) as semester values
57    row['semester'] = str(row['semester'])
58    if row['semester'] == '1':
59        first.append(row)
60    elif row['semester'] == '2':
61        second.append(row)       
62    else:
63        combined.append(row)
64first.sort()
65second.sort()
66combined.sort()
67info['first'] = first
68info['second'] = second
69info['combined'] = combined
70
71return info
Note: See TracBrowser for help on using the repository browser.