1 | ## Script (Python) "getStudentInfo" |
---|
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: getClearanceInfo.py 1102 2006-12-20 09:47:34Z joachim $ |
---|
11 | """ |
---|
12 | return Info about the current Student |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('Student.Clearance.Info') |
---|
16 | |
---|
17 | request = context.REQUEST |
---|
18 | mtool = context.portal_membership |
---|
19 | wf = context.portal_workflow |
---|
20 | member = mtool.getAuthenticatedMember() |
---|
21 | member_id = str(member) |
---|
22 | path_info = request.get('PATH_INFO').split('/') |
---|
23 | |
---|
24 | if mtool.isAnonymousUser(): |
---|
25 | return None |
---|
26 | info = {} |
---|
27 | #from Products.zdb import set_trace |
---|
28 | #set_trace() |
---|
29 | requested_id = context.getStudentId() |
---|
30 | if requested_id and not context.isStaff() and member_id != requested_id: |
---|
31 | logger.info('"%s", "tried to access", "%s"' % (member_id,requested_id)) |
---|
32 | return None |
---|
33 | elif context.isStaff(): |
---|
34 | student_id = requested_id |
---|
35 | else: |
---|
36 | student_id = member_id |
---|
37 | |
---|
38 | |
---|
39 | students_object = context.portal_url.getPortalObject().campus.students |
---|
40 | student = getattr(students_object, student_id) |
---|
41 | info['id'] = student_id |
---|
42 | info['student'] = student |
---|
43 | info['review_state'] = wf.getInfoFor(student,'review_state',None) |
---|
44 | #info['app'] = student.application |
---|
45 | #info['app_doc'] = student.application.getContent() |
---|
46 | info['clear'] = student.clearance |
---|
47 | info['clear_doc'] = student.clearance.getContent() |
---|
48 | info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None) |
---|
49 | return info |
---|