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

Last change on this file since 17406 was 5160, checked in by Henrik Bettermann, 15 years ago

change certificate in certificates_catalog instead of portal_catalog (see ticket #665)

New admitted student were not able to access the portal_catalog (don't know why).

  • Property svn:keywords set to Id
File size: 2.5 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
[1048]7##parameters=student=None, with_items=None
[535]8##title=
9##
[805]10# $Id: getStudentInfo.py 5160 2010-04-20 11:23:17Z 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
[1006]22import logging
[1571]23logger = logging.getLogger('Skins.getStudentInfo')
[1006]24
[1144]25
[535]26info = {}
27member_id = str(member)
[1006]28#from Products.zdb import set_trace
29#set_trace()
30student_id = None
[645]31if student is None:
[1006]32    while True:
33        if mtool.isAnonymousUser():
34            return None
35        try:
36            requested_id = path_info[path_info.index('students')+1]
[1016]37        except (ValueError,IndexError):
[1006]38            student_id = member_id
39            break
40        if not context.isStudent() and 'students' in path_info:
41            student_id = requested_id
42            break
43        if member_id != requested_id:
[1571]44            logger.info('%s tried to access %s' % (member_id,requested_id))
[1006]45            student_id = member_id
[1025]46            mtool.assertViewable(context)
[1006]47            break
[748]48        student_id = member_id
[1006]49        break
[645]50else:
51    student_id = student.getId()
[1006]52
[1048]53#roles = member.getRoles()
[787]54student_path = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id)
[785]55student = context.restrictedTraverse(student_path,default=None)
[971]56
[1006]57if student is None or student.portal_type != "Student":
[639]58    return None
[1144]59
[1871]60info['review_state'] = context.getStudentReviewState()
[535]61info['student'] = student
[584]62info['id'] = student.getId()
[662]63info['url'] = student.absolute_url()
[538]64info['student_doc'] = student.getContent()
[1179]65info['app'] = student.application
66info['app_doc'] = student.application.getContent()
[2920]67info['has_passport'] = context.waeup_tool.picturesExist(('passport',), student_id)
[2407]68
[785]69course = getattr(student,'study_course',None)
[5160]70
[785]71if course:
[1025]72    cert_id = course.getContent().study_course
[5160]73    res = context.certificates_catalog(code=cert_id)
[1025]74    ci = {}
75    if len(res) > 0:
76        info['course'] = course
77        brain = res[0]
[5160]78        ci['study_course'] = brain.code
79        ci['title'] = brain.title
80        ci['faculty'] = brain.faculty
81        ci['department'] = brain.department
[1025]82        info['course_doc'] = ci
83    else:
84        info['course'] = None
[2043]85
[1067]86if not with_items:
87    return info
88
[742]89request.set('student_id',student_id)
90request.set('student_url',info['url'])
[535]91return info
Note: See TracBrowser for help on using the repository browser.