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

Last change on this file since 734 was 723, checked in by joachim, 18 years ago

Import and Manager view for full-time students + results

File size: 2.9 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():
28        if context.portal_type == 'Student':
29            student_id = context.getId()
30        else:
31            student_id = context.aq_parent.getId()
32    else:
33        student_id = member_id
34else:
35    student_id = student.getId()
36res = context.portal_catalog(id = student_id,portal_type='Student')
37if not res or len(res) > 1:
38    return None
39brain = res[-1]
40student = brain.getObject()
41student_path = brain.getPath()
42info['review_state'] = wf.getInfoFor(student,'review_state','keiner')
43info['student'] = student
44info['id'] = student.getId()
45info['url'] = student.absolute_url()
46info['student_doc'] = student.getContent()
47info['app'] = student.application
48info['app_doc'] = student.application.getContent()
49info['per'] = student.personal
50info['per_doc'] = student.personal.getContent()
51info['sex'] = 'male'
52if info['per_doc'].sex:
53    info['sex'] = 'female'
54res = context.portal_catalog(container_path=student_path,
55                             portal_type='StudentAccommodation')
56if res:
57    acco = res[0].getObject()
58    info['acco'] = acco
59    info['acco_doc'] = acco.getContent()
60else:
61    info['acco'] = None
62
63items = []
64s_edit_links = {'StudentApplication': 'student_edit',
65              'StudentAccommodation': '',
66              'StudentPersonal': '',
67              }
68s_view_links = {'StudentApplication': None,
69              'StudentAccommodation': None,
70              'StudentPersonal': None,
71              'StudentStudyCourse': 'study_course_view',
72              }
73sos = context.portal_catalog(container_path=student_path)
74for so in sos:
75    row = {}
76    soo = so.getObject()
77    sod = soo.getContent()
78    row['id'] = soo.getId()
79    row['title'] = sod.Title()
80    row['url'] = soo.absolute_url()
81    row['type'] = so.portal_type
82    row['is_editable'] = mtool.checkPermission('Modify portal content', soo)
83    sv_link = s_view_links.get(so.portal_type,None) or "academics_document_view"
84    row['s_view_link'] = "%s/%s" % (soo.absolute_url(),sv_link)
85    se_link = s_edit_links.get(so.portal_type,None)
86    row['s_edit_link'] = None
87    if se_link:
88        row['s_edit_link'] = "%s/%s" % (student.absolute_url(),se_link)
89    row['review_state'] = so.review_state
90    row['display'] = so.review_state in ('opened','closed')
91    items.append(row)
92info['items'] = items
93return info
Note: See TracBrowser for help on using the repository browser.