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

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

some code cleaning

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
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 5163 2010-04-21 04:38:00Z henrik $
11"""
12return Info about the current Student
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19import logging
20logger = logging.getLogger('Skins.getClearanceInfo')
21import DateTime
22now = DateTime.DateTime()
23
24
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
32
33info = context.waeup_tool.getAccessInfo(context)
34
35info['timestamp'] = "%d" % int(now.timeTime()*1000)
36
37student_id = info['student_id']
38if student_id is None:
39    return None
40if 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
44student_record = context.students_catalog.getRecordByKey(student_id)
45students_object = context.portal_url.getPortalObject().campus.students
46student = 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'))
52info['penalty'] = False
53info['id'] = student_id
54info['student'] = student
55info['student_name'] = student_record.name
56#info['review_state'] = context.getStudentReviewState()
57info['review_state'] = student_record.review_state
58info['app'] = student.application
59try:
60    info['app_doc'] = student.application.getContent()
61except:
62    return
63info['clear'] = student.clearance
64try:
65    info['clear_doc'] = student.clearance.getContent()
66except:
67    return   
68info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None)
69info['per'] = student.personal
70info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None)
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'))
79return info
Note: See TracBrowser for help on using the repository browser.