source: WAeUP_SRP/trunk/skins/waeup_student/getIdCardInfo.py @ 5164

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

some code cleaning

File size: 1.6 KB
RevLine 
[2043]1## Script (Python) "getIdCardInfo"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: getTransferInfo.py 1339 2007-01-21 22:55:34Z henrik $
11"""
12return Info about the current Student
13"""
14import logging
15logger = logging.getLogger('Skins.getIdCardInfo')
16from DateTime import DateTime
17
18request = context.REQUEST
19mtool = context.portal_membership
20wf = context.portal_workflow
21member = mtool.getAuthenticatedMember()
22member_id = str(member)
23
[2047]24
[4030]25#if member_id not in ('admin','isouaba',):
26#    return None
[2047]27
[2043]28if mtool.isAnonymousUser():
29    return None
30info = {}
31#from Products.zdb import set_trace
32#set_trace()
33requested_id = context.getStudentId()
34if requested_id and not context.isStaff() and member_id != requested_id:
35    logger.info('%s tried to access %s' % (member_id,requested_id))
36    return None
37elif context.isStaff():
38    student_id = requested_id
39else:
40    student_id = member_id
41
42
43students_object = context.portal_url.getPortalObject().campus.students
44student = getattr(students_object,student_id)
45
46res = context.students_catalog(id = student_id)
47if len(res) != 1:
48    return None
49sbrain = res[0]
50info['id'] = student_id
51info['scatalog'] = context.getFormattedStudentEntry(sbrain)
52info['student'] = student
53#info['entry_mode'] = sbrain.entry_mode
54
55personal = getattr(student,'personal',None)
56if personal:
57    personal_doc = personal.getContent()
58    info['personal'] = personal_doc
59
[2045]60
[4030]61info['passport_url'] = context.portal_url() + '/viewimage/' + student_id + '/passport_' + student_id + '.jpg'
62
[2043]63return info
Note: See TracBrowser for help on using the repository browser.