source: WAeUP_SRP/trunk/skins/waeup_academics/getLevelInfo.py @ 4121

Last change on this file since 4121 was 3474, checked in by joachim, 17 years ago

introduce breadcrumbs for the academic-section, use them instead of up one
level.

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