[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 2975 2008-01-03 17:20:02Z joachim $ |
---|
| 11 | """ |
---|
| 12 | return Info about the current Student |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
[1571] | 15 | logger = logging.getLogger('Skins.getClearanceInfo') |
---|
[1141] | 16 | from DateTime import DateTime |
---|
[1073] | 17 | |
---|
| 18 | request = context.REQUEST |
---|
| 19 | mtool = context.portal_membership |
---|
| 20 | wf = context.portal_workflow |
---|
| 21 | member = mtool.getAuthenticatedMember() |
---|
| 22 | member_id = str(member) |
---|
| 23 | path_info = request.get('PATH_INFO').split('/') |
---|
| 24 | |
---|
[2975] | 25 | # if mtool.isAnonymousUser(): |
---|
| 26 | # return None |
---|
| 27 | # info = {} |
---|
| 28 | # #from Products.zdb import set_trace |
---|
| 29 | # #set_trace() |
---|
| 30 | # requested_id = context.getStudentId() |
---|
| 31 | # if requested_id and not context.isStaff() and member_id != requested_id: |
---|
| 32 | # logger.info('%s tried to access %s' % (member_id,requested_id)) |
---|
| 33 | # return None |
---|
| 34 | # elif context.isStaff(): |
---|
| 35 | # student_id = requested_id |
---|
| 36 | # else: |
---|
| 37 | # student_id = member_id |
---|
| 38 | |
---|
| 39 | info = context.waeup_tool.getAccessInfo(context) |
---|
| 40 | student_id = info['student_id'] |
---|
| 41 | if student_id is None: |
---|
[1073] | 42 | return None |
---|
| 43 | |
---|
| 44 | students_object = context.portal_url.getPortalObject().campus.students |
---|
| 45 | student = getattr(students_object, student_id) |
---|
[1141] | 46 | res = context.portal_catalog(portal_type='Student',id = student_id) |
---|
| 47 | if len(res) == 0: |
---|
| 48 | return None |
---|
| 49 | creation_date = DateTime(res[0].CreationDate) |
---|
[1157] | 50 | info['penalty'] = creation_date.lessThan(DateTime('2006/12/5')) |
---|
[1073] | 51 | info['id'] = student_id |
---|
| 52 | info['student'] = student |
---|
[1871] | 53 | info['review_state'] = context.getStudentReviewState() |
---|
[1141] | 54 | info['app'] = student.application |
---|
| 55 | info['app_doc'] = student.application.getContent() |
---|
[1073] | 56 | info['clear'] = student.clearance |
---|
| 57 | info['clear_doc'] = student.clearance.getContent() |
---|
| 58 | info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None) |
---|
[2670] | 59 | info['per'] = student.personal |
---|
| 60 | info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None) |
---|
[1162] | 61 | if info['review_state'] in ('clearance_requested', 'cleared_and_validated',): |
---|
[1156] | 62 | info['penalty'] = info['penalty'] and\ |
---|
[1157] | 63 | info['clear_doc'].entry_date.greaterThan(DateTime('2006/12/30')) |
---|
[1156] | 64 | course = getattr(student,'study_course',None) |
---|
| 65 | if course: |
---|
| 66 | cert_id = course.getContent().study_course |
---|
| 67 | res = context.portal_catalog(portal_type = "Certificate", id = cert_id) |
---|
| 68 | ci = {} |
---|
| 69 | if len(res) > 0: |
---|
| 70 | info['course'] = course |
---|
| 71 | brain = res[0] |
---|
| 72 | ci['study_course'] = brain.getId |
---|
| 73 | ci['title'] = brain.Title |
---|
| 74 | pl = brain.getPath().split('/') |
---|
| 75 | ci['faculty'] = pl[-4] |
---|
| 76 | ci['department'] = pl[-3] |
---|
| 77 | info['course_doc'] = ci |
---|
| 78 | else: |
---|
| 79 | info['course'] = None |
---|
[1073] | 80 | return info |
---|