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 | mtool = context.portal_membership |
---|
18 | path_info = request.get('PATH_INFO').split('/') |
---|
19 | try: |
---|
20 | i = int(path_info[-1]) |
---|
21 | p = 0 |
---|
22 | except: |
---|
23 | p = 1 |
---|
24 | info = {} |
---|
25 | pt = request.get('PATH_TRANSLATED').split('/') |
---|
26 | |
---|
27 | dep_id = pt[-(3+p)] |
---|
28 | cert_id = pt[-(2+p)] |
---|
29 | level_id = pt[-(1+p)] |
---|
30 | info['is_manager'] = context.isManager() |
---|
31 | info['is_student'] = context.isStudent() |
---|
32 | info['action'] = "%s" % context.absolute_url() |
---|
33 | info['choosen_ids'] = request.get('ids',[]) |
---|
34 | info['doc'] = context.getContent() |
---|
35 | brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1] |
---|
36 | cp = brain.getPath() |
---|
37 | info['container_path'] = cp |
---|
38 | info['dep_id'] = dep_id |
---|
39 | info['cert_id'] = cert_id |
---|
40 | |
---|
41 | res = context.portal_catalog(meta_type="CertificateCourse", container_path="%s/%s" % (cp,level_id)) |
---|
42 | first = [] |
---|
43 | second = [] |
---|
44 | for r in res: |
---|
45 | row = {} |
---|
46 | ro = r.getObject() |
---|
47 | rd = ro.getContent() |
---|
48 | row['id'] = r.getId |
---|
49 | row['title'] = rd.Title() |
---|
50 | row['core'] = rd.core_or_elective |
---|
51 | row['semester'] = rd.semester |
---|
52 | row['url'] = ro.absolute_url() |
---|
53 | row['review_state'] = wf.getInfoFor(ro,'review_state','None') |
---|
54 | row['is_editable'] = mtool.checkPermission('Modify portal content', ro) |
---|
55 | if rd.semester == 'first': |
---|
56 | first.append(row) |
---|
57 | else: |
---|
58 | second.append(row) |
---|
59 | first.sort() |
---|
60 | second.sort() |
---|
61 | info['first'] = first |
---|
62 | info['second'] = second |
---|
63 | return info |
---|