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 | """ |
---|
12 | return Info about the Faculties |
---|
13 | """ |
---|
14 | request = context.REQUEST |
---|
15 | |
---|
16 | wf = context.portal_workflow |
---|
17 | mtool = context.portal_membership |
---|
18 | academics_path = "%s/campus/academics" % context.portal_url() |
---|
19 | path_info = request.get('PATH_INFO').split('/') |
---|
20 | try: |
---|
21 | i = int(path_info[-1]) |
---|
22 | p = 0 |
---|
23 | except: |
---|
24 | p = 1 |
---|
25 | info = {} |
---|
26 | pt = request.get('PATH_INFO').split('/') |
---|
27 | |
---|
28 | dep_id = pt[-(3+p)] |
---|
29 | cert_id = pt[-(2+p)] |
---|
30 | level_id = pt[-(1+p)] |
---|
31 | info['action'] = "%s" % context.absolute_url() |
---|
32 | info['choosen_ids'] = request.get('ids',[]) |
---|
33 | info['doc'] = context.getContent() |
---|
34 | info['dep_id'] = dep_id |
---|
35 | info['cert_id'] = cert_id |
---|
36 | |
---|
37 | |
---|
38 | first = [] |
---|
39 | second = [] |
---|
40 | combined = [] |
---|
41 | for 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) |
---|
64 | first.sort() |
---|
65 | second.sort() |
---|
66 | combined.sort() |
---|
67 | info['first'] = first |
---|
68 | info['second'] = second |
---|
69 | info['combined'] = combined |
---|
70 | |
---|
71 | return info |
---|