[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 3455 2008-04-21 07:45:34Z 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') |
---|
[1141] | 21 | from DateTime import DateTime |
---|
[1073] | 22 | |
---|
| 23 | request = context.REQUEST |
---|
| 24 | mtool = context.portal_membership |
---|
| 25 | wf = context.portal_workflow |
---|
| 26 | member = mtool.getAuthenticatedMember() |
---|
| 27 | member_id = str(member) |
---|
| 28 | path_info = request.get('PATH_INFO').split('/') |
---|
| 29 | |
---|
[2975] | 30 | # if mtool.isAnonymousUser(): |
---|
| 31 | # return None |
---|
| 32 | # info = {} |
---|
| 33 | # #from Products.zdb import set_trace |
---|
| 34 | # #set_trace() |
---|
| 35 | # requested_id = context.getStudentId() |
---|
| 36 | # if requested_id and not context.isStaff() and member_id != requested_id: |
---|
| 37 | # logger.info('%s tried to access %s' % (member_id,requested_id)) |
---|
| 38 | # return None |
---|
| 39 | # elif context.isStaff(): |
---|
| 40 | # student_id = requested_id |
---|
| 41 | # else: |
---|
| 42 | # student_id = member_id |
---|
| 43 | |
---|
| 44 | info = context.waeup_tool.getAccessInfo(context) |
---|
| 45 | student_id = info['student_id'] |
---|
| 46 | if student_id is None: |
---|
[1073] | 47 | return None |
---|
| 48 | |
---|
[3452] | 49 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
[1073] | 50 | students_object = context.portal_url.getPortalObject().campus.students |
---|
| 51 | student = getattr(students_object, student_id) |
---|
[3452] | 52 | # res = context.portal_catalog(portal_type='Student',id = student_id) |
---|
| 53 | # if len(res) == 0: |
---|
| 54 | # return None |
---|
| 55 | # creation_date = DateTime(res[0].CreationDate) |
---|
| 56 | # info['penalty'] = creation_date.lessThan(DateTime('2006/12/5')) |
---|
| 57 | info['penalty'] = False |
---|
[1073] | 58 | info['id'] = student_id |
---|
| 59 | info['student'] = student |
---|
[3452] | 60 | info['student_name'] = student_record.name |
---|
| 61 | #info['review_state'] = context.getStudentReviewState() |
---|
| 62 | info['review_state'] = student_record.review_state |
---|
[3455] | 63 | info['app'] = student.application |
---|
[1141] | 64 | info['app_doc'] = student.application.getContent() |
---|
[1073] | 65 | info['clear'] = student.clearance |
---|
| 66 | info['clear_doc'] = student.clearance.getContent() |
---|
| 67 | info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None) |
---|
[2670] | 68 | info['per'] = student.personal |
---|
| 69 | info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None) |
---|
[3452] | 70 | ci = {} |
---|
| 71 | ci['course'] = student_record.course |
---|
| 72 | ci['faculty'] = student_record.faculty |
---|
| 73 | ci['department'] = student_record.department |
---|
| 74 | info['course_doc'] = ci |
---|
| 75 | # if info['review_state'] in ('clearance_requested', 'cleared_and_validated',): |
---|
| 76 | # info['penalty'] = info['penalty'] and\ |
---|
| 77 | # info['clear_doc'].entry_date.greaterThan(DateTime('2006/12/30')) |
---|
| 78 | # course = getattr(student,'study_course',None) |
---|
| 79 | # if course: |
---|
| 80 | # cert_id = course.getContent().study_course |
---|
| 81 | # res = context.portal_catalog(portal_type = "Certificate", id = cert_id) |
---|
| 82 | # ci = {} |
---|
| 83 | # if len(res) > 0: |
---|
| 84 | # info['course'] = course |
---|
| 85 | # brain = res[0] |
---|
| 86 | # ci['study_course'] = brain.getId |
---|
| 87 | # ci['title'] = brain.Title |
---|
| 88 | # pl = brain.getPath().split('/') |
---|
| 89 | # ci['faculty'] = pl[-4] |
---|
| 90 | # ci['department'] = pl[-3] |
---|
| 91 | # info['course_doc'] = ci |
---|
| 92 | # else: |
---|
| 93 | # info['course'] = None |
---|
[1073] | 94 | return info |
---|