| 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 1653 2007-03-28 02:35:25Z uli $ |
|---|
| 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 | brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1] |
|---|
| 35 | cp = brain.getPath() |
|---|
| 36 | info['container_path'] = cp |
|---|
| 37 | info['dep_id'] = dep_id |
|---|
| 38 | info['cert_id'] = cert_id |
|---|
| 39 | |
|---|
| 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 = row['id'] = r.getId |
|---|
| 48 | row['title'] = rd.Title() |
|---|
| 49 | row['core'] = rd.core_or_elective |
|---|
| 50 | row['semester'] = rd.semester |
|---|
| 51 | row['url'] = ro.absolute_url() |
|---|
| 52 | row['review_state'] = wf.getInfoFor(ro,'review_state','None') |
|---|
| 53 | editable = row['is_editable'] = mtool.checkPermission('Modify portal content', ro) |
|---|
| 54 | if editable: |
|---|
| 55 | course_res = context.courses_catalog(code=course_id) |
|---|
| 56 | if course_res: |
|---|
| 57 | rc = course_res[0] |
|---|
| 58 | row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path,rc.faculty,rc.department,course_id) |
|---|
| 59 | if rd.semester == 'first': |
|---|
| 60 | first.append(row) |
|---|
| 61 | else: |
|---|
| 62 | second.append(row) |
|---|
| 63 | first.sort() |
|---|
| 64 | second.sort() |
|---|
| 65 | info['first'] = first |
|---|
| 66 | info['second'] = second |
|---|
| 67 | return info |
|---|