source: WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py @ 586

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

search form for students ready for testing.

File size: 3.1 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
20student_wf_states = wf.waeup_student_wf.states.keys()
21info['wf_states'] = student_wf_states
22info['wf_states'][0] = " ----- "
23mtool = context.portal_membership
24member = mtool.getAuthenticatedMember()
25lt = context.portal_layouts
26pr = context.portal_registration
27path_info = request.get('PATH_INFO').split('/')
28roles = member.getRoles()
29is_manager = 'Manager' in roles or 'SectionManager' in roles
30validate = request.has_key("cpsdocument_edit_button")
31items = []
32default = {'search_mode': 'name',
33        'review_state': 'admission_applied ',
34        'search_string': 'yy'
35        }
36       
37rend,psm,ds = lt.renderLayout(layout_id= 'student_search',
38                      schema_id= 'student_search',
39                      context=context,
40                      mapping=validate and request,
41                      ob=default,
42                      layout_mode='edit',
43                      formaction="searchStudents"
44                      )
45if psm == '':
46    return context.students_manager_view(rendered = rend,
47                             psm = psm,
48                             #psm = "%s, %s" % (psm,ds),
49                             students = items,
50                             is_manager = is_manager,
51                             )
52what = ds.get('search_mode')
53state = ds.get('review_state')
54term = ds.get('search_string')
55if state == " ----- ":
56    state = ''
57onlyreview = state and what == "review_state"
58items = []
59res = []
60portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']}
61if onlyreview:
62    res = catalog(portal_type=portal_type_query,
63                  review_state=state)
64elif what == "student_id":
65    res = catalog(portal_type='Student',
66                  id = student_id.strip())
67elif what == "jamb_id":
68    res = catalog(portal_type='StudentApplication',
69                  SearchableText="%s*" % term.strip().lower())
70elif what == "matric_no":
71    res = catalog(portal_type='StudentClearance',
72                  SearchableText="%s*" % term.strip().lower())
73elif what == "name":
74    res = catalog(portal_type=portal_type_query,
75                  SearchableText="%s*" % term.strip())
76if res:
77    for r in res:
78        row = {}
79        if r.portal_type in ("StudentApplication","StudentPersonal"):
80            items.append(r.getObject().aq_parent)
81        else:
82            items.append(r.getObject())
83students = []
84if items:
85    for item in items:
86        students.append(context.getStudentInfo(item))
87return context.students_manager_view(rendered = rend,
88                             psm = "%d matching Students found" % len(items),
89                             #psm = "%s, %s" % (psm,ds),
90                             students = students,
91                             is_manager = is_manager,
92                             )
Note: See TracBrowser for help on using the repository browser.