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

Last change on this file since 877 was 867, checked in by joachim, 18 years ago

patch for default field width in stringWidgets
isClearanceOfficer added

  • Property svn:keywords set to Id
File size: 3.8 KB
RevLine 
[845]1## Script (Python) "getStudentInfo"
[535]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##
[805]10# $Id: getStudentInfo.py 867 2006-11-14 16:15:38Z joachim $
[535]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:
[787]28    if mtool.isAnonymousUser():
29        return None
30    elif context.isManager() and 'students' in path_info:
[741]31        student_id = path_info[path_info.index('students')+1]
[646]32    else:
[748]33        student_id = member_id
[645]34else:
35    student_id = student.getId()
[787]36student_path = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id)
[785]37student = context.restrictedTraverse(student_path,default=None)
38if student is None or student.portal_type != 'Student':
[639]39    return None
[785]40##res = context.portal_catalog(id = student_id,portal_type='Student')
41##if not res:# or len(res) > 1:
42##    return None
43##brain = res[-1]
44##student = brain.getObject()
[742]45info['review_state'] = wf.getInfoFor(student,'review_state',None)
[535]46info['student'] = student
[584]47info['id'] = student.getId()
[662]48info['url'] = student.absolute_url()
[538]49info['student_doc'] = student.getContent()
[535]50info['app'] = student.application
51info['app_doc'] = student.application.getContent()
52info['per'] = student.personal
53info['per_doc'] = student.personal.getContent()
[785]54course = getattr(student,'study_course',None)
[867]55#
[785]56info['course'] = course
57if course:
58    info['course_doc'] = student.study_course.getContent()
[635]59info['sex'] = 'male'
60if info['per_doc'].sex:
61    info['sex'] = 'female'
[867]62#
[812]63acco = getattr(student,'accommodation_2006',None)
[785]64info['acco'] = acco
65if acco is not None:
[639]66    info['acco_doc'] = acco.getContent()
[748]67    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
[867]68#
[785]69clear = getattr(student,'clearance',None)
70info['clear'] = clear
71if clear is not None:
[766]72    info['clear_doc'] = clear.getContent()
73    info['clear_review_state'] = wf.getInfoFor(clear,'review_state',None)
[867]74#
[785]75pume = getattr(student,'pume',None)
76info['pume'] = pume
77if pume is not None:
[768]78    info['pume_doc'] = pume.getContent()
79    info['pume_review_state'] = wf.getInfoFor(pume,'review_state',None)
80else:
[770]81    info['pume'] = None
[659]82
83items = []
[803]84s_edit_links = {'StudentApplication': 'application_edit_form',
[814]85              'StudentAccommodation': 'reserve_accommodation',
[803]86              'StudentClearance': 'clearance_edit_form',
[672]87              'StudentPersonal': '',
88              }
[770]89s_view_links = {'StudentApplication': 'application_view',
[748]90              'StudentAccommodation': 'accommodation_view',
[768]91              'StudentClearance': 'clearance_view',
[723]92              'StudentPersonal': None,
93              'StudentStudyCourse': 'study_course_view',
[768]94              'StudentPume': 'pume_view',
[674]95              }
[659]96sos = context.portal_catalog(container_path=student_path)
[656]97for so in sos:
98    row = {}
99    soo = so.getObject()
100    sod = soo.getContent()
101    row['id'] = soo.getId()
102    row['title'] = sod.Title()
103    row['url'] = soo.absolute_url()
[659]104    row['type'] = so.portal_type
[656]105    row['is_editable'] = mtool.checkPermission('Modify portal content', soo)
[739]106    sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
[723]107    row['s_view_link'] = "%s/%s" % (soo.absolute_url(),sv_link)
[674]108    se_link = s_edit_links.get(so.portal_type,None)
109    row['s_edit_link'] = None
110    if se_link:
[767]111        row['s_edit_link'] = "%s/%s" % (soo.absolute_url(),se_link)
[659]112    row['review_state'] = so.review_state
[849]113    row['display'] = so.review_state in ('opened','closed',)
[656]114    items.append(row)
115info['items'] = items
[742]116request.set('student_id',student_id)
117request.set('student_url',info['url'])
[535]118return info
Note: See TracBrowser for help on using the repository browser.