source: WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py @ 739

Last change on this file since 739 was 739, checked in by Henrik Bettermann, 18 years ago

academics_document_view.pt renamed and moved

File size: 3.3 KB
Line 
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"""
12return Info about the current Student
13"""
14request = context.REQUEST
15form = request.form
16fget = form.get
17wf = context.portal_workflow
18mtool = context.portal_membership
19member = mtool.getAuthenticatedMember()
20path_info = request.get('PATH_INFO').split('/')
21roles = member.getRoles()
22info = {}
23info['is_manager'] = context.isManager()
24info['is_student'] = context.isStudent()
25member_id = str(member)
26if student is None:
27    if context.isManager() and 'students' in context.getPhysicalPath():
28        if context.portal_type == 'Student':
29            student_id = context.getId()
30        elif context.aq_parent.portal_type == 'Student':
31            student_id = context.aq_parent.getId()
32        elif context.aq_parent.aq_parent.portal_type == 'Student':
33            student_id = context.aq_parent.aq_parent.getId()
34        elif context.aq_parent.aq_parent.aq_parent.portal_type == 'Student':
35            student_id = context.aq_parent.aq_parent.aq_parent.getId()
36        else:
37            student_id = member_id
38    else:
39        student_id = member_id
40else:
41    student_id = student.getId()
42res = context.portal_catalog(id = student_id,portal_type='Student')
43if not res or len(res) > 1:
44    return None
45brain = res[-1]
46student = brain.getObject()
47student_path = brain.getPath()
48info['review_state'] = wf.getInfoFor(student,'review_state','keiner')
49info['student'] = student
50info['id'] = student.getId()
51info['url'] = student.absolute_url()
52info['student_doc'] = student.getContent()
53info['app'] = student.application
54info['app_doc'] = student.application.getContent()
55info['per'] = student.personal
56info['per_doc'] = student.personal.getContent()
57info['sex'] = 'male'
58if info['per_doc'].sex:
59    info['sex'] = 'female'
60res = context.portal_catalog(container_path=student_path,
61                             portal_type='StudentAccommodation')
62if res:
63    acco = res[0].getObject()
64    info['acco'] = acco
65    info['acco_doc'] = acco.getContent()
66else:
67    info['acco'] = None
68
69items = []
70s_edit_links = {'StudentApplication': 'student_edit',
71              'StudentAccommodation': '',
72              'StudentPersonal': '',
73              }
74s_view_links = {'StudentApplication': None,
75              'StudentAccommodation': None,
76              'StudentPersonal': None,
77              'StudentStudyCourse': 'study_course_view',
78              }
79sos = context.portal_catalog(container_path=student_path)
80for so in sos:
81    row = {}
82    soo = so.getObject()
83    sod = soo.getContent()
84    row['id'] = soo.getId()
85    row['title'] = sod.Title()
86    row['url'] = soo.absolute_url()
87    row['type'] = so.portal_type
88    row['is_editable'] = mtool.checkPermission('Modify portal content', soo)
89    sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
90    row['s_view_link'] = "%s/%s" % (soo.absolute_url(),sv_link)
91    se_link = s_edit_links.get(so.portal_type,None)
92    row['s_edit_link'] = None
93    if se_link:
94        row['s_edit_link'] = "%s/%s" % (student.absolute_url(),se_link)
95    row['review_state'] = so.review_state
96    row['display'] = so.review_state in ('opened','closed')
97    items.append(row)
98info['items'] = items
99return info
Note: See TracBrowser for help on using the repository browser.