source: WAeUP_SRP/trunk/skins/waeup_student/getSessionResults.py @ 1177

Last change on this file since 1177 was 1174, checked in by Henrik Bettermann, 18 years ago

sessional result view and slip added
names imported into application object

File size: 1.9 KB
Line 
1## Script (Python) "getSessionResults"
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: display_session_results.py 1166 2006-12-31 18:11:47Z henrik $
11"""
12process the Application Form
13return html renderer + psm
14"""
15import DateTime
16current = DateTime.DateTime()
17pr = context.portal_registration
18
19returning = context.returning_import
20results = context.results_import
21
22mtool = context.portal_membership
23member = mtool.getAuthenticatedMember()
24member_id = str(member)
25
26if mtool.isAnonymousUser():
27    return None
28info = {}
29#from Products.zdb import set_trace
30#set_trace()
31requested_id = context.getStudentId()
32if requested_id and not context.isStaff() and member_id != requested_id:
33    logger.info('"%s", "tried to access", "%s"' % (member_id,requested_id))
34    return None
35elif context.isStaff():
36    student_id = requested_id
37else:
38    student_id = member_id
39
40students_object = context.portal_url.getPortalObject().campus.students
41student = getattr(students_object, student_id)
42
43
44clear = getattr(student,'clearance',None)
45if clear:
46    value = clear.getContent().matric_no
47else:
48    return None
49
50res = returning(matric_no = value)
51student = res[0]
52res = results(matric_no = value)
53results = res
54
55
56sem1 = []
57sem2 = []
58with_courses_cat = hasattr(context,'courses_catalog')
59fields = context.results_import.schema()
60for r in results:
61    result = {}
62    for field in fields:
63        result[field] = getattr(r,field)
64    if with_courses_cat:
65        res = context.courses_catalog(code = r.CosCode)
66    if with_courses_cat and res:
67        result['title'] = res[0].title
68    else:
69        result['title'] = "To Be Determined"
70    if r.Semester == '2':
71        sem2.append(result)
72    else:
73        sem1.append(result)
74info['results'] = (sem1, sem2)
75info['student'] = student
76info['s_id'] = student_id
77return info
Note: See TracBrowser for help on using the repository browser.