[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 3474 2008-04-29 13:13:32Z joachim $ |
---|
[556] | 11 | """ |
---|
[3473] | 12 | return Info about the Level |
---|
| 13 | try: |
---|
| 14 | from Products.zdb import set_trace |
---|
| 15 | except: |
---|
| 16 | def set_trace(): |
---|
| 17 | pass |
---|
[3474] | 18 | """ |
---|
[556] | 19 | request = context.REQUEST |
---|
| 20 | |
---|
| 21 | wf = context.portal_workflow |
---|
[614] | 22 | mtool = context.portal_membership |
---|
[1631] | 23 | academics_path = "%s/campus/academics" % context.portal_url() |
---|
[556] | 24 | path_info = request.get('PATH_INFO').split('/') |
---|
[573] | 25 | try: |
---|
| 26 | i = int(path_info[-1]) |
---|
| 27 | p = 0 |
---|
| 28 | except: |
---|
| 29 | p = 1 |
---|
[556] | 30 | info = {} |
---|
[1514] | 31 | pt = request.get('PATH_INFO').split('/') |
---|
[573] | 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() |
---|
[556] | 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 | |
---|
[2614] | 42 | |
---|
[565] | 43 | first = [] |
---|
| 44 | second = [] |
---|
[2614] | 45 | combined = [] |
---|
[2609] | 46 | for course_id,course in context.objectItems(): |
---|
[565] | 47 | row = {} |
---|
[2609] | 48 | course_doc = course.getContent() |
---|
[2281] | 49 | row = context.getCourseInfo(course_id) |
---|
| 50 | row['id'] = course_id |
---|
[2609] | 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) |
---|
[1631] | 55 | if editable: |
---|
[2281] | 56 | row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path, |
---|
| 57 | row['faculty'], |
---|
| 58 | row['department'], |
---|
| 59 | course_id) |
---|
[2614] | 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': |
---|
[565] | 64 | first.append(row) |
---|
[2614] | 65 | elif row['semester'] == '2': |
---|
| 66 | second.append(row) |
---|
[565] | 67 | else: |
---|
[2614] | 68 | combined.append(row) |
---|
[566] | 69 | first.sort() |
---|
| 70 | second.sort() |
---|
[2614] | 71 | combined.sort() |
---|
[565] | 72 | info['first'] = first |
---|
| 73 | info['second'] = second |
---|
[2614] | 74 | info['combined'] = combined |
---|
| 75 | |
---|
[556] | 76 | return info |
---|