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

Last change on this file since 1156 was 1156, checked in by joachim, 18 years ago

clearance_slip now also uses getClearanceInfo, which has been extended.

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1## Script (Python) "getStudentInfo"
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 1156 2006-12-30 12:36:01Z joachim $
11"""
12return Info about the current Student
13"""
14import logging
15logger = logging.getLogger('Student.Clearance.Info')
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
25if mtool.isAnonymousUser():
26    return None
27info = {}
28#from Products.zdb import set_trace
29#set_trace()
30requested_id = context.getStudentId()
31if 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
34elif context.isStaff():
35    student_id = requested_id
36else:
37    student_id = member_id
38
39
40students_object = context.portal_url.getPortalObject().campus.students
41student = getattr(students_object, student_id)
42res = context.portal_catalog(portal_type='Student',id = student_id)
43if len(res) == 0:
44    return None
45creation_date = DateTime(res[0].CreationDate)
46info['penalty'] = creation_date.lessThan(DateTime('2006/12/5'))\
47                  and DateTime().greaterThan(DateTime('2006/12/30'))
48info['id'] = student_id
49info['student'] = student
50info['review_state'] = wf.getInfoFor(student,'review_state',None)
51info['app'] = student.application
52info['app_doc'] = student.application.getContent()
53info['clear'] = student.clearance
54info['clear_doc'] = student.clearance.getContent()
55info['clear_review_state'] = wf.getInfoFor(student.clearance,'review_state',None)
56if info['clear_review_state'] == "clearance_requested":
57    info['penalty'] = info['penalty'] and\
58                      info['clear_doc'].entry_date.lessThan(DateTime('2006/12/30'))
59course = getattr(student,'study_course',None)
60if course:
61    cert_id = course.getContent().study_course
62    res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
63    ci = {}
64    if len(res) > 0:
65        info['course'] = course
66        brain = res[0]
67        ci['study_course'] = brain.getId
68        ci['title'] = brain.Title
69        pl = brain.getPath().split('/')
70        ci['faculty'] = pl[-4]
71        ci['department'] = pl[-3]
72        info['course_doc'] = ci
73    else:
74        info['course'] = None
75return info
Note: See TracBrowser for help on using the repository browser.