[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 | """ |
---|
| 12 | return Info about the Faculties |
---|
| 13 | """ |
---|
| 14 | request = context.REQUEST |
---|
| 15 | |
---|
| 16 | wf = context.portal_workflow |
---|
[614] | 17 | mtool = context.portal_membership |
---|
[1631] | 18 | academics_path = "%s/campus/academics" % context.portal_url() |
---|
[556] | 19 | path_info = request.get('PATH_INFO').split('/') |
---|
[573] | 20 | try: |
---|
| 21 | i = int(path_info[-1]) |
---|
| 22 | p = 0 |
---|
| 23 | except: |
---|
| 24 | p = 1 |
---|
[556] | 25 | info = {} |
---|
[1514] | 26 | pt = request.get('PATH_INFO').split('/') |
---|
[573] | 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() |
---|
[556] | 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 | |
---|
[2614] | 37 | |
---|
[565] | 38 | first = [] |
---|
| 39 | second = [] |
---|
[2614] | 40 | combined = [] |
---|
[2609] | 41 | for 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] | 64 | first.sort() |
---|
| 65 | second.sort() |
---|
[2614] | 66 | combined.sort() |
---|
[565] | 67 | info['first'] = first |
---|
| 68 | info['second'] = second |
---|
[2614] | 69 | info['combined'] = combined |
---|
| 70 | |
---|
[556] | 71 | return info |
---|