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

Last change on this file since 3081 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
RevLine 
[845]1## Script (Python) "getLevelInfo"
[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: getLevelInfo.py 2614 2007-11-09 21:30:03Z henrik $
[556]11"""
12return Info about the Faculties
13"""
14request = context.REQUEST
15
16wf = context.portal_workflow
[614]17mtool = context.portal_membership
[1631]18academics_path = "%s/campus/academics" % context.portal_url()
[556]19path_info = request.get('PATH_INFO').split('/')
[573]20try:
21    i = int(path_info[-1])
22    p = 0
23except:
24    p = 1
[556]25info = {}
[1514]26pt = request.get('PATH_INFO').split('/')
[573]27
28dep_id = pt[-(3+p)]
29cert_id = pt[-(2+p)]
30level_id = pt[-(1+p)]
31info['action'] = "%s" % context.absolute_url()
[556]32info['choosen_ids'] = request.get('ids',[])
33info['doc'] = context.getContent()
34info['dep_id'] = dep_id
35info['cert_id'] = cert_id
36
[2614]37
[565]38first = []
39second = []
[2614]40combined = []
[2609]41for course_id,course in context.objectItems():
[565]42    row = {}
[2609]43    course_doc = course.getContent()
[2281]44    row = context.getCourseInfo(course_id)
45    row['id'] = course_id
[2609]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)
[1631]50    if editable:
[2281]51        row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path,
52                                                           row['faculty'],
53                                                           row['department'],
54                                                           course_id)
[2614]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':
[565]59        first.append(row)
[2614]60    elif row['semester'] == '2':
61        second.append(row)       
[565]62    else:
[2614]63        combined.append(row)
[566]64first.sort()
65second.sort()
[2614]66combined.sort()
[565]67info['first'] = first
68info['second'] = second
[2614]69info['combined'] = combined
70
[556]71return info
Note: See TracBrowser for help on using the repository browser.