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

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

student's navigation modified

File size: 2.2 KB
RevLine 
[535]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
[563]15form = request.form
16fget = form.get
[535]17wf = context.portal_workflow
18mtool = context.portal_membership
19member = mtool.getAuthenticatedMember()
20path_info = request.get('PATH_INFO').split('/')
[563]21roles = member.getRoles()
[535]22info = {}
[603]23info['is_manager'] = context.isManager
[659]24info['is_student'] = context.isStudent()
[535]25member_id = str(member)
[645]26if student is None:
[648]27    if context.isManager():
[646]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
[645]34else:
35    student_id = student.getId()
[648]36res = context.portal_catalog(id = student_id,portal_type='Student')
37if not res or len(res) > 1:
[639]38    return None
[648]39brain = res[-1]
[639]40student = brain.getObject()
[656]41student_path = brain.getPath()
[535]42info['review_state'] = wf.getInfoFor(student,'review_state','keiner')
43info['student'] = student
[584]44info['id'] = student.getId()
[662]45info['url'] = student.absolute_url()
[538]46info['student_doc'] = student.getContent()
[535]47info['app'] = student.application
48info['app_doc'] = student.application.getContent()
49info['per'] = student.personal
50info['per_doc'] = student.personal.getContent()
[635]51info['sex'] = 'male'
52if info['per_doc'].sex:
53    info['sex'] = 'female'
[639]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
[659]62
63items = []
64sos = context.portal_catalog(container_path=student_path)
[656]65for so in sos:
66    row = {}
67    soo = so.getObject()
68    sod = soo.getContent()
69    row['id'] = soo.getId()
70    row['title'] = sod.Title()
71    row['url'] = soo.absolute_url()
[659]72    row['type'] = so.portal_type
[656]73    row['is_editable'] = mtool.checkPermission('Modify portal content', soo)
[659]74    row['review_state'] = so.review_state
[656]75    items.append(row)
76info['items'] = items
[535]77return info
Note: See TracBrowser for help on using the repository browser.