source: WAeUP_SRP/trunk/skins/waeup_student/getClearanceInfo.py @ 11504

Last change on this file since 11504 was 5163, checked in by Henrik Bettermann, 15 years ago

some code cleaning

  • Property svn:keywords set to Id
File size: 2.4 KB
RevLine 
[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"""
12return Info about the current Student
13"""
[3452]14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
[1073]19import logging
[1571]20logger = logging.getLogger('Skins.getClearanceInfo')
[5133]21import DateTime
22now = DateTime.DateTime()
[1073]23
[5133]24
[1073]25request = context.REQUEST
26mtool = context.portal_membership
27wf = context.portal_workflow
28member = mtool.getAuthenticatedMember()
29member_id = str(member)
30path_info = request.get('PATH_INFO').split('/')
31
[2975]32
33info = context.waeup_tool.getAccessInfo(context)
[5133]34
35info['timestamp'] = "%d" % int(now.timeTime()*1000)
36
[2975]37student_id = info['student_id']
38if student_id is None:
[1073]39    return None
[5028]40if 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]44student_record = context.students_catalog.getRecordByKey(student_id)
[1073]45students_object = context.portal_url.getPortalObject().campus.students
46student = 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'))
52info['penalty'] = False
[1073]53info['id'] = student_id
54info['student'] = student
[3452]55info['student_name'] = student_record.name
56#info['review_state'] = context.getStudentReviewState()
57info['review_state'] = student_record.review_state
[3455]58info['app'] = student.application
[3619]59try:
60    info['app_doc'] = student.application.getContent()
61except:
62    return
[1073]63info['clear'] = student.clearance
[3619]64try:
65    info['clear_doc'] = student.clearance.getContent()
66except:
67    return   
[1073]68info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None)
[2670]69info['per'] = student.personal
70info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None)
[3452]71ci = {}
72ci['course'] = student_record.course
73ci['faculty'] = student_record.faculty
74ci['department'] = student_record.department
75info['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]79return info
Note: See TracBrowser for help on using the repository browser.