source: WAeUP_SRP/base/skins/waeup_student/getClearanceInfo.py @ 2975

Last change on this file since 2975 was 2975, checked in by joachim, 17 years ago
  • Property svn:keywords set to Id
File size: 2.5 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 2975 2008-01-03 17:20:02Z joachim $
11"""
12return Info about the current Student
13"""
14import logging
15logger = logging.getLogger('Skins.getClearanceInfo')
16from DateTime import DateTime
17
18request = context.REQUEST
19mtool = context.portal_membership
20wf = context.portal_workflow
21member = mtool.getAuthenticatedMember()
22member_id = str(member)
23path_info = request.get('PATH_INFO').split('/')
24
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
39info = context.waeup_tool.getAccessInfo(context)
40student_id = info['student_id']
41if student_id is None:
42    return None
43
44students_object = context.portal_url.getPortalObject().campus.students
45student = getattr(students_object, student_id)
46res = context.portal_catalog(portal_type='Student',id = student_id)
47if len(res) == 0:
48    return None
49creation_date = DateTime(res[0].CreationDate)
50info['penalty'] = creation_date.lessThan(DateTime('2006/12/5'))
51info['id'] = student_id
52info['student'] = student
53info['review_state'] = context.getStudentReviewState()
54info['app'] = student.application
55info['app_doc'] = student.application.getContent()
56info['clear'] = student.clearance
57info['clear_doc'] = student.clearance.getContent()
58info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None)
59info['per'] = student.personal
60info['per_review_state'] = wf.getInfoFor(student.personal,'review_state',None)
61if info['review_state'] in ('clearance_requested', 'cleared_and_validated',):
62    info['penalty'] = info['penalty'] and\
63                      info['clear_doc'].entry_date.greaterThan(DateTime('2006/12/30'))
64course = getattr(student,'study_course',None)
65if 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
80return info
Note: See TracBrowser for help on using the repository browser.