1 | ## Script (Python) "getClearanceInfo" |
---|
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 5163 2010-04-21 04:38:00Z henrik $ |
---|
11 | """ |
---|
12 | return Info about the current Student |
---|
13 | """ |
---|
14 | try: |
---|
15 | from Products.zdb import set_trace |
---|
16 | except: |
---|
17 | def set_trace(): |
---|
18 | pass |
---|
19 | import logging |
---|
20 | logger = logging.getLogger('Skins.getClearanceInfo') |
---|
21 | import DateTime |
---|
22 | now = DateTime.DateTime() |
---|
23 | |
---|
24 | |
---|
25 | request = context.REQUEST |
---|
26 | mtool = context.portal_membership |
---|
27 | wf = context.portal_workflow |
---|
28 | member = mtool.getAuthenticatedMember() |
---|
29 | member_id = str(member) |
---|
30 | path_info = request.get('PATH_INFO').split('/') |
---|
31 | |
---|
32 | |
---|
33 | info = context.waeup_tool.getAccessInfo(context) |
---|
34 | |
---|
35 | info['timestamp'] = "%d" % int(now.timeTime()*1000) |
---|
36 | |
---|
37 | student_id = info['student_id'] |
---|
38 | if student_id is None: |
---|
39 | return None |
---|
40 | if info['is_staff'] and not info['is_clearanceofficer'] and not info['is_sectionofficer']: |
---|
41 | logger.info('%s tried to access %s' % (member_id,student_id)) |
---|
42 | return None |
---|
43 | |
---|
44 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
45 | students_object = context.portal_url.getPortalObject().campus.students |
---|
46 | student = getattr(students_object, student_id) |
---|
47 | # res = context.portal_catalog(portal_type='Student',id = student_id) |
---|
48 | # if len(res) == 0: |
---|
49 | # return None |
---|
50 | # creation_date = DateTime(res[0].CreationDate) |
---|
51 | # info['penalty'] = creation_date.lessThan(DateTime('2006/12/5')) |
---|
52 | info['penalty'] = False |
---|
53 | info['id'] = student_id |
---|
54 | info['student'] = student |
---|
55 | info['student_name'] = student_record.name |
---|
56 | #info['review_state'] = context.getStudentReviewState() |
---|
57 | info['review_state'] = student_record.review_state |
---|
58 | info['app'] = student.application |
---|
59 | try: |
---|
60 | info['app_doc'] = student.application.getContent() |
---|
61 | except: |
---|
62 | return |
---|
63 | info['clear'] = student.clearance |
---|
64 | try: |
---|
65 | info['clear_doc'] = student.clearance.getContent() |
---|
66 | except: |
---|
67 | return |
---|
68 | info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None) |
---|
69 | info['per'] = student.personal |
---|
70 | info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None) |
---|
71 | ci = {} |
---|
72 | ci['course'] = student_record.course |
---|
73 | ci['faculty'] = student_record.faculty |
---|
74 | ci['department'] = student_record.department |
---|
75 | info['course_doc'] = ci |
---|
76 | # if info['review_state'] in ('clearance_requested', 'cleared_and_validated',): |
---|
77 | # info['penalty'] = info['penalty'] and\ |
---|
78 | # info['clear_doc'].entry_date.greaterThan(DateTime('2006/12/30')) |
---|
79 | return info |
---|