[1161] | 1 | ## Script (Python) "getClearanceInfo" |
---|
[1073] | 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 | """ |
---|
[3452] | 14 | try: |
---|
| 15 | from Products.zdb import set_trace |
---|
| 16 | except: |
---|
| 17 | def set_trace(): |
---|
| 18 | pass |
---|
[1073] | 19 | import logging |
---|
[1571] | 20 | logger = logging.getLogger('Skins.getClearanceInfo') |
---|
[5133] | 21 | import DateTime |
---|
| 22 | now = DateTime.DateTime() |
---|
[1073] | 23 | |
---|
[5133] | 24 | |
---|
[1073] | 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 | |
---|
[2975] | 32 | |
---|
| 33 | info = context.waeup_tool.getAccessInfo(context) |
---|
[5133] | 34 | |
---|
| 35 | info['timestamp'] = "%d" % int(now.timeTime()*1000) |
---|
| 36 | |
---|
[2975] | 37 | student_id = info['student_id'] |
---|
| 38 | if student_id is None: |
---|
[1073] | 39 | return None |
---|
[5028] | 40 | if info['is_staff'] and not info['is_clearanceofficer'] and not info['is_sectionofficer']: |
---|
[5029] | 41 | logger.info('%s tried to access %s' % (member_id,student_id)) |
---|
[5028] | 42 | return None |
---|
[1073] | 43 | |
---|
[3452] | 44 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
[1073] | 45 | students_object = context.portal_url.getPortalObject().campus.students |
---|
| 46 | student = getattr(students_object, student_id) |
---|
[3452] | 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 |
---|
[1073] | 53 | info['id'] = student_id |
---|
| 54 | info['student'] = student |
---|
[3452] | 55 | info['student_name'] = student_record.name |
---|
| 56 | #info['review_state'] = context.getStudentReviewState() |
---|
| 57 | info['review_state'] = student_record.review_state |
---|
[3455] | 58 | info['app'] = student.application |
---|
[3619] | 59 | try: |
---|
| 60 | info['app_doc'] = student.application.getContent() |
---|
| 61 | except: |
---|
| 62 | return |
---|
[1073] | 63 | info['clear'] = student.clearance |
---|
[3619] | 64 | try: |
---|
| 65 | info['clear_doc'] = student.clearance.getContent() |
---|
| 66 | except: |
---|
| 67 | return |
---|
[1073] | 68 | info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None) |
---|
[2670] | 69 | info['per'] = student.personal |
---|
| 70 | info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None) |
---|
[3452] | 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')) |
---|
[1073] | 79 | return info |
---|