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

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

is_* keys removed from get* functions

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