[556] | 1 | ## Script (Python) "cpsdocument_edit" |
---|
| 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: student_edit.py 486 2006-09-06 10:09:39Z joachim $ |
---|
| 11 | """ |
---|
| 12 | return Info about the Faculties |
---|
| 13 | """ |
---|
| 14 | request = context.REQUEST |
---|
| 15 | |
---|
| 16 | wf = context.portal_workflow |
---|
| 17 | path_info = request.get('PATH_INFO').split('/') |
---|
[573] | 18 | try: |
---|
| 19 | i = int(path_info[-1]) |
---|
| 20 | p = 0 |
---|
| 21 | except: |
---|
| 22 | p = 1 |
---|
[556] | 23 | info = {} |
---|
| 24 | pt = request.get('PATH_TRANSLATED').split('/') |
---|
[573] | 25 | |
---|
| 26 | dep_id = pt[-(3+p)] |
---|
| 27 | cert_id = pt[-(2+p)] |
---|
| 28 | level_id = pt[-(1+p)] |
---|
[600] | 29 | info['is_manager'] = context.isManager() |
---|
| 30 | info['is_student'] = context.isStudent() |
---|
[573] | 31 | info['action'] = "%s" % context.absolute_url() |
---|
[556] | 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 | |
---|
[565] | 40 | res = context.portal_catalog(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 | row['id'] = r.getId |
---|
| 48 | row['title'] = rd.Title() |
---|
[603] | 49 | row['core'] = rd.core_or_elective |
---|
[565] | 50 | row['semester'] = rd.semester |
---|
| 51 | row['url'] = ro.absolute_url() |
---|
[573] | 52 | row['review_state'] = wf.getInfoFor(ro,'review_state','None') |
---|
[598] | 53 | row['is_editable'] = mtool.checkPermission('Modify portal content', ro) |
---|
[565] | 54 | if rd.semester == 'first': |
---|
| 55 | first.append(row) |
---|
| 56 | else: |
---|
| 57 | second.append(row) |
---|
[566] | 58 | first.sort() |
---|
| 59 | second.sort() |
---|
[565] | 60 | info['first'] = first |
---|
| 61 | info['second'] = second |
---|
[556] | 62 | return info |
---|