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 current Student |
---|
13 | """ |
---|
14 | request = context.REQUEST |
---|
15 | form = request.form |
---|
16 | fget = form.get |
---|
17 | wf = context.portal_workflow |
---|
18 | mtool = context.portal_membership |
---|
19 | member = mtool.getAuthenticatedMember() |
---|
20 | path_info = request.get('PATH_INFO').split('/') |
---|
21 | roles = member.getRoles() |
---|
22 | info = {} |
---|
23 | info['is_manager'] = context.isManager |
---|
24 | member_id = str(member) |
---|
25 | if student is None: |
---|
26 | if context.isManager(): |
---|
27 | if context.portal_type == 'Student': |
---|
28 | student_id = context.getId() |
---|
29 | else: |
---|
30 | student_id = context.aq_parent.getId() |
---|
31 | else: |
---|
32 | student_id = member_id |
---|
33 | else: |
---|
34 | student_id = student.getId() |
---|
35 | res = context.portal_catalog(id = student_id,portal_type='Student') |
---|
36 | if not res or len(res) > 1: |
---|
37 | return None |
---|
38 | brain = res[-1] |
---|
39 | student = brain.getObject() |
---|
40 | student_path = brain.getPath() |
---|
41 | info['review_state'] = wf.getInfoFor(student,'review_state','keiner') |
---|
42 | info['student'] = student |
---|
43 | info['id'] = student.getId() |
---|
44 | info['student_doc'] = student.getContent() |
---|
45 | info['app'] = student.application |
---|
46 | info['app_doc'] = student.application.getContent() |
---|
47 | info['per'] = student.personal |
---|
48 | info['per_doc'] = student.personal.getContent() |
---|
49 | info['sex'] = 'male' |
---|
50 | if info['per_doc'].sex: |
---|
51 | info['sex'] = 'female' |
---|
52 | res = context.portal_catalog(container_path=student_path, |
---|
53 | portal_type='StudentAccommodation') |
---|
54 | if res: |
---|
55 | acco = res[0].getObject() |
---|
56 | info['acco'] = acco |
---|
57 | info['acco_doc'] = acco.getContent() |
---|
58 | else: |
---|
59 | info['acco'] = None |
---|
60 | return info |
---|