1 | ## Script (Python) "getDepartmentsInfo" |
---|
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: getDepartmentsInfo.py 1988 2007-07-05 11:14:12Z joachim $ |
---|
11 | """ |
---|
12 | return Info about the Faculties |
---|
13 | """ |
---|
14 | try: |
---|
15 | from Products.zdb import set_trace |
---|
16 | except: |
---|
17 | def set_trace(): |
---|
18 | pass |
---|
19 | request = context.REQUEST |
---|
20 | |
---|
21 | wf = context.portal_workflow |
---|
22 | mtool = context.portal_membership |
---|
23 | member = mtool.getAuthenticatedMember() |
---|
24 | #path_info = request.get('PATH_INFO').split('/') |
---|
25 | |
---|
26 | info = {} |
---|
27 | member_id = str(member) |
---|
28 | roles = member.getRolesInContext(context) |
---|
29 | info['action'] = "%s" % context.absolute_url() |
---|
30 | info['choosen_ids'] = request.get('ids',[]) |
---|
31 | items = [] |
---|
32 | info['doc'] = context.getContent() |
---|
33 | # set_trace() |
---|
34 | # brain = context.portal_catalog(portal_type="Faculty", id = context.getId())[-1] |
---|
35 | # cp = brain.getPath() |
---|
36 | cp = request.get('PATH_INFO') |
---|
37 | info['container_path'] = cp |
---|
38 | res = context.portal_catalog(container_path=cp) |
---|
39 | for r in res: |
---|
40 | row = {} |
---|
41 | ro = r.getObject() |
---|
42 | rd = ro.getContent() |
---|
43 | row['id'] = r.getId |
---|
44 | row['title'] = rd.LongTitle() |
---|
45 | row['url'] = ro.absolute_url() |
---|
46 | row['is_editable'] = mtool.checkPermission('Modify portal content', ro) |
---|
47 | items.append(row) |
---|
48 | info['items'] = items |
---|
49 | return info |
---|