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 5133 2010-04-06 09:30:16Z 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 | # course = getattr(student,'study_course',None) |
---|
80 | # if course: |
---|
81 | # cert_id = course.getContent().study_course |
---|
82 | # res = context.portal_catalog(portal_type = "Certificate", id = cert_id) |
---|
83 | # ci = {} |
---|
84 | # if len(res) > 0: |
---|
85 | # info['course'] = course |
---|
86 | # brain = res[0] |
---|
87 | # ci['study_course'] = brain.getId |
---|
88 | # ci['title'] = brain.Title |
---|
89 | # pl = brain.getPath().split('/') |
---|
90 | # ci['faculty'] = pl[-4] |
---|
91 | # ci['department'] = pl[-3] |
---|
92 | # info['course_doc'] = ci |
---|
93 | # else: |
---|
94 | # info['course'] = None |
---|
95 | return info |
---|