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

Last change on this file since 751 was 750, checked in by joachim, 18 years ago

searchStudents now supports new review_states, not yet fully tested

File size: 3.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()
[741]22
[535]23info = {}
[723]24info['is_manager'] = context.isManager()
[659]25info['is_student'] = context.isStudent()
[535]26member_id = str(member)
[645]27if student is None:
[741]28    if context.isManager() and 'students' in path_info:
29        student_id = path_info[path_info.index('students')+1]
[646]30    else:
[748]31        student_id = member_id
[645]32else:
33    student_id = student.getId()
[648]34res = context.portal_catalog(id = student_id,portal_type='Student')
[742]35if not res:# or len(res) > 1:
[639]36    return None
[648]37brain = res[-1]
[639]38student = brain.getObject()
[656]39student_path = brain.getPath()
[742]40info['review_state'] = wf.getInfoFor(student,'review_state',None)
[535]41info['student'] = student
[584]42info['id'] = student.getId()
[662]43info['url'] = student.absolute_url()
[538]44info['student_doc'] = student.getContent()
[535]45info['app'] = student.application
46info['app_doc'] = student.application.getContent()
47info['per'] = student.personal
48info['per_doc'] = student.personal.getContent()
[635]49info['sex'] = 'male'
50if info['per_doc'].sex:
51    info['sex'] = 'female'
[639]52res = context.portal_catalog(container_path=student_path,
53                             portal_type='StudentAccommodation')
54if res:
55    acco = res[0].getObject()
56    info['acco'] = acco
57    info['acco_doc'] = acco.getContent()
[748]58    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
[639]59else:
60    info['acco'] = None
[659]61
62items = []
[672]63s_edit_links = {'StudentApplication': 'student_edit',
64              'StudentAccommodation': '',
65              'StudentPersonal': '',
66              }
[723]67s_view_links = {'StudentApplication': None,
[748]68              'StudentAccommodation': 'accommodation_view',
[723]69              'StudentPersonal': None,
[748]70              'StudentApplication': 'application_view',
[723]71              'StudentStudyCourse': 'study_course_view',
[674]72              }
[659]73sos = context.portal_catalog(container_path=student_path)
[656]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()
[659]81    row['type'] = so.portal_type
[656]82    row['is_editable'] = mtool.checkPermission('Modify portal content', soo)
[739]83    sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
[723]84    row['s_view_link'] = "%s/%s" % (soo.absolute_url(),sv_link)
[674]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)
[659]89    row['review_state'] = so.review_state
[750]90    row['display'] = so.review_state in ('opened','closed',) or\
91                     so.portal_type in ("StudentAccommodation","StudentStudyCourse")
[656]92    items.append(row)
93info['items'] = items
[742]94request.set('student_id',student_id)
95request.set('student_url',info['url'])
[535]96return info
Note: See TracBrowser for help on using the repository browser.