source: WAeUP_SRP/trunk/skins/waeup_academics/searchAcademics.py @ 609

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

batch of fixes to open the frontend for the first time

File size: 3.2 KB
Line 
1## Script (Python) "cpsdocument_edit"
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: student_edit.py 486 2006-09-06 10:09:39Z joachim $
11"""
12return Info about the current Student
13"""
14request = context.REQUEST
15form = request.form
16fget = form.get
17info = {}
18wf = context.portal_workflow
19catalog = context.portal_catalog
20lt = context.portal_layouts
21pr = context.portal_registration
22path_info = request.get('PATH_INFO').split('/')
23is_manager = context.isManager
24validate = request.has_key("cpsdocument_edit_button")
25items = []
26default = {'search_mode': 'course',
27        'review_state': 'unchecked',
28        'search_string': ''
29        }
30
31rend,psm,ds = lt.renderLayout(layout_id= 'academics_search',
32                      schema_id= 'academics_search',
33                      context=context,
34                      mapping=validate and request,
35                      ob=default,
36                      layout_mode='edit',
37                      formaction="searchAcademics"
38                      )
39if psm == '':
40    return context.academics_search_view(rendered = rend,
41                             psm = psm,
42                             #psm = "%s, %s" % (psm,ds),
43                             objects = items,
44                             is_manager = is_manager,
45                             )
46what = ds.get('search_mode')
47state = ds.get('review_state')
48term = ds.get('search_string')
49if state == " ----- ":
50    state = ''
51if not term and what in ('student_edit','jamb_reg_no','name','matric_no'):
52    return context.academics_search_view(rendered = rend,
53                             psm = "You must specify a search string",
54                             #psm = "%s, %s" % (psm,ds),
55                             objects = items,
56                             is_manager = is_manager,
57                             )
58onlyreview = state and what == "review_state"
59items = []
60res = []
61portal_type_query = {'query':['Department','Course','CertificateCourse']}
62if onlyreview:
63    res = catalog(portal_type=portal_type_query,
64                  review_state=state)
65elif what == "student_id":
66    res = catalog(portal_type='Student',
67                  id = term.strip())
68elif what == "jamb_reg_no":
69    res = catalog(portal_type='StudentApplication',
70                  SearchableText="%s*" % term.strip().lower())
71elif what == "matric_no":
72    res = catalog(portal_type='StudentClearance',
73                  SearchableText="%s*" % term.strip().lower())
74elif what == "name":
75    res = catalog(portal_type=portal_type_query,
76                  SearchableText="%s*" % term.strip())
77if res:
78    for r in res:
79        row = {}
80        if r.portal_type in ("StudentApplication","StudentPersonal"):
81            items.append(r.getObject().aq_parent)
82        else:
83            items.append(r.getObject())
84objects = []
85if items:
86    for item in items:
87        objects.append(context.getStudentInfo(item))
88return context.academics_search_view(rendered = rend,
89                             psm = "%d matching objects found" % len(items),
90                             #psm = "%s, %s" % (psm,ds),
91                             objects = objects,
92                             is_manager = is_manager,
93                             )
Note: See TracBrowser for help on using the repository browser.