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

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

resolve #656 (in custom)

  • Property svn:keywords set to Id
File size: 3.2 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 5028 2010-02-22 08:55:55Z 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')
21from DateTime import DateTime
22
23request = context.REQUEST
24mtool = context.portal_membership
25wf = context.portal_workflow
26member = mtool.getAuthenticatedMember()
27member_id = str(member)
28path_info = request.get('PATH_INFO').split('/')
29
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
44info = context.waeup_tool.getAccessInfo(context)
45student_id = info['student_id']
46if student_id is None:
47    return None
48if info['is_staff'] and not info['is_clearanceofficer'] and not info['is_sectionofficer']:
49    return None
50
51student_record = context.students_catalog.getRecordByKey(student_id)
52students_object = context.portal_url.getPortalObject().campus.students
53student = getattr(students_object, student_id)
54# res = context.portal_catalog(portal_type='Student',id = student_id)
55# if len(res) == 0:
56#     return None
57# creation_date = DateTime(res[0].CreationDate)
58# info['penalty'] = creation_date.lessThan(DateTime('2006/12/5'))
59info['penalty'] = False
60info['id'] = student_id
61info['student'] = student
62info['student_name'] = student_record.name
63#info['review_state'] = context.getStudentReviewState()
64info['review_state'] = student_record.review_state
65info['app'] = student.application
66try:
67    info['app_doc'] = student.application.getContent()
68except:
69    return
70info['clear'] = student.clearance
71try:
72    info['clear_doc'] = student.clearance.getContent()
73except:
74    return   
75info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None)
76info['per'] = student.personal
77info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None)
78ci = {}
79ci['course'] = student_record.course
80ci['faculty'] = student_record.faculty
81ci['department'] = student_record.department
82info['course_doc'] = ci
83# if info['review_state'] in ('clearance_requested', 'cleared_and_validated',):
84#     info['penalty'] = info['penalty'] and\
85#                       info['clear_doc'].entry_date.greaterThan(DateTime('2006/12/30'))
86# course = getattr(student,'study_course',None)
87# if course:
88#     cert_id = course.getContent().study_course
89#     res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
90#     ci = {}
91#     if len(res) > 0:
92#         info['course'] = course
93#         brain = res[0]
94#         ci['study_course'] = brain.getId
95#         ci['title'] = brain.Title
96#         pl = brain.getPath().split('/')
97#         ci['faculty'] = pl[-4]
98#         ci['department'] = pl[-3]
99#         info['course_doc'] = ci
100#     else:
101#         info['course'] = None
102return info
Note: See TracBrowser for help on using the repository browser.