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