source: WAeUP_SRP/trunk/skins/waeup_student/display_session_results.py @ 1827

Last change on this file since 1827 was 1796, checked in by Henrik Bettermann, 17 years ago

some fixes to display the correct object actions
also one fix regarding ticket #214

  • Property svn:keywords set to Id
File size: 3.2 KB
RevLine 
[1146]1##parameters=REQUEST
2# $Id: display_session_results.py 1796 2007-05-18 10:52:31Z henrik $
3"""
4process the Application Form
5return html renderer + psm
6"""
7import DateTime
8current = DateTime.DateTime()
9pr = context.portal_registration
10
11validate = REQUEST.has_key("cpsdocument_create_button")
12
13lt = context.portal_layouts
14#pr = context.portal_registration
15
16res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search',
[1151]17                      schema_id= 'student_returning',
[1146]18                      context=context,
19                      mapping=validate and REQUEST,
20                      ob={},
21                      layout_mode='create',
22                      formaction = "display_session_results",
23                      button = "Search",
24                      commit=False,
25                      )
26if psm == 'invalid':
27    return context.display_session_results_form(rendered = res,
28                                 psm = "Please correct your input!",
29                                 #psm = "%s, %s" % (psm,ds),
30                                 firstlayout = True,
31                                 lastlayout = True,
32                                 ds = ds,
33                                 )
34elif psm == '':
35    return context.display_session_results_form(rendered = res,
36                                 psm = None,
37                                 firstlayout = True,
38                                 lastlayout = True,
39                                 ds = ds,
40                                 )
41elif psm == 'valid':
[1165]42    pass
[1183]43s_fields = context.returning_import.schema()
44student_rec = ds.get('student')
45student = {}
46for field in s_fields:
47    student[field] = getattr(student_rec,field)
[1165]48brains = ds.get('results')
49sem1 = []
50sem2 = []
51with_courses_cat = hasattr(context,'courses_catalog')
[1183]52
[1165]53fields = context.results_import.schema()
[1183]54verdict = None
55session = None
[1165]56for r in brains:
[1183]57    if verdict is None:
58        verdict = r.Verdict
59        session = r.Session
[1165]60    result = {}
61    for field in fields:
62        result[field] = getattr(r,field)
63    if with_courses_cat:
64        res = context.courses_catalog(code = r.CosCode)
[1448]65    if r.CosCode == 'N/A':
66        result['title'] = 'N/A'
67    elif with_courses_cat and res:
[1165]68        result['title'] = res[0].title
69    else:
[1166]70        result['title'] = "To Be Determined"
[1165]71    if r.Semester == '2':
72        sem2.append(result)
73    else:
74        sem1.append(result)
75#from Products.zdb import set_trace;set_trace()
76results = (sem1, sem2)
[1183]77student['verdict'] = verdict
78student['session'] = session
[1175]79registered = None
[1794]80res = context.returning_import(matric_no = student_rec.matric_no)
[1175]81if res:
82    student_id = res[0].id
[1796]83
84    #There was one student with empty id in returning_import (BMS0406035)
85    student_obj = None
86    if student_id:
87        student_obj = getattr(context.portal_url.getPortalObject().campus.students,student_id,None)
88    else:
89        registered = ' '
90
[1175]91    if student_obj and hasattr(student_obj,'application'):
92        registered = student_id
[1177]93else:
94    registered = "no_student_object"
[1183]95return context.session_results_anon_view(student=student,
[1175]96                                           results=results,
[1177]97                                           name = "%(Firstname)s %(Middlename)s %(Lastname)s" % student_rec,
[1175]98                                           registered = registered)
[1146]99
Note: See TracBrowser for help on using the repository browser.