[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 2609 2007-11-09 15:38:22Z joachim $ |
---|
[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() |
---|
[2609] | 34 | # brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1] |
---|
| 35 | # cp = brain.getPath() |
---|
| 36 | # info['container_path'] = cp |
---|
[556] | 37 | info['dep_id'] = dep_id |
---|
| 38 | info['cert_id'] = cert_id |
---|
| 39 | |
---|
[2609] | 40 | # res = context.portal_catalog(meta_type="CertificateCourse", container_path="%s/%s" % (cp,level_id)) |
---|
| 41 | # first = [] |
---|
| 42 | # second = [] |
---|
| 43 | # for r in res: |
---|
| 44 | # row = {} |
---|
| 45 | # ro = r.getObject() |
---|
| 46 | # rd = ro.getContent() |
---|
| 47 | # course_id = r.getId |
---|
| 48 | # row = context.getCourseInfo(course_id) |
---|
| 49 | # row['id'] = course_id |
---|
| 50 | # # row['title'] = rd.Title() |
---|
| 51 | # # row['semester'] = rd.semester |
---|
| 52 | # row['core'] = rd.core_or_elective |
---|
| 53 | # row['url'] = ro.absolute_url() |
---|
| 54 | # row['review_state'] = wf.getInfoFor(ro,'review_state','None') |
---|
| 55 | # editable = row['is_editable'] = mtool.checkPermission('Modify portal content', ro) |
---|
| 56 | # if editable: |
---|
| 57 | # row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path, |
---|
| 58 | # row['faculty'], |
---|
| 59 | # row['department'], |
---|
| 60 | # course_id) |
---|
| 61 | # if row['semester'] == 1: |
---|
| 62 | # first.append(row) |
---|
| 63 | # else: |
---|
| 64 | # second.append(row) |
---|
[565] | 65 | first = [] |
---|
| 66 | second = [] |
---|
[2609] | 67 | for course_id,course in context.objectItems(): |
---|
[565] | 68 | row = {} |
---|
[2609] | 69 | # ro = r.getObject() |
---|
| 70 | course_doc = course.getContent() |
---|
| 71 | # course_id = r.getId |
---|
[2281] | 72 | row = context.getCourseInfo(course_id) |
---|
| 73 | row['id'] = course_id |
---|
[2609] | 74 | # row['title'] = course_doc.Title() |
---|
| 75 | # row['semester'] = course_doc.semester |
---|
| 76 | row['core'] = course_doc.core_or_elective |
---|
| 77 | row['url'] = course.absolute_url() |
---|
| 78 | row['review_state'] = wf.getInfoFor(course,'review_state','None') |
---|
| 79 | editable = row['is_editable'] = mtool.checkPermission('Modify portal content', course) |
---|
[1631] | 80 | if editable: |
---|
[2281] | 81 | row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path, |
---|
| 82 | row['faculty'], |
---|
| 83 | row['department'], |
---|
| 84 | course_id) |
---|
| 85 | if row['semester'] == 1: |
---|
[565] | 86 | first.append(row) |
---|
| 87 | else: |
---|
| 88 | second.append(row) |
---|
[566] | 89 | first.sort() |
---|
| 90 | second.sort() |
---|
[565] | 91 | info['first'] = first |
---|
| 92 | info['second'] = second |
---|
[556] | 93 | return info |
---|