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 | """ |
---|
12 | return Info about the current Student |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('Skins.getIdCardInfo') |
---|
16 | from DateTime import DateTime |
---|
17 | |
---|
18 | request = context.REQUEST |
---|
19 | mtool = context.portal_membership |
---|
20 | wf = context.portal_workflow |
---|
21 | member = mtool.getAuthenticatedMember() |
---|
22 | member_id = str(member) |
---|
23 | |
---|
24 | |
---|
25 | #if member_id not in ('admin','isouaba',): |
---|
26 | # return None |
---|
27 | |
---|
28 | if mtool.isAnonymousUser(): |
---|
29 | return None |
---|
30 | info = {} |
---|
31 | #from Products.zdb import set_trace |
---|
32 | #set_trace() |
---|
33 | requested_id = context.getStudentId() |
---|
34 | if 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 |
---|
37 | elif context.isStaff(): |
---|
38 | student_id = requested_id |
---|
39 | else: |
---|
40 | student_id = member_id |
---|
41 | |
---|
42 | |
---|
43 | students_object = context.portal_url.getPortalObject().campus.students |
---|
44 | student = getattr(students_object,student_id) |
---|
45 | |
---|
46 | res = context.students_catalog(id = student_id) |
---|
47 | if len(res) != 1: |
---|
48 | return None |
---|
49 | sbrain = res[0] |
---|
50 | info['id'] = student_id |
---|
51 | info['scatalog'] = context.getFormattedStudentEntry(sbrain) |
---|
52 | info['student'] = student |
---|
53 | #info['entry_mode'] = sbrain.entry_mode |
---|
54 | |
---|
55 | personal = getattr(student,'personal',None) |
---|
56 | if personal: |
---|
57 | personal_doc = personal.getContent() |
---|
58 | info['personal'] = personal_doc |
---|
59 | |
---|
60 | |
---|
61 | info['passport_url'] = context.portal_url() + '/viewimage/' + student_id + '/passport_' + student_id + '.jpg' |
---|
62 | |
---|
63 | return info |
---|