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

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

changed layout in student_search

File size: 3.5 KB
RevLine 
[565]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
[584]7##parameters=
[565]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
[572]17info = {}
[565]18wf = context.portal_workflow
[572]19catalog = context.portal_catalog
20student_wf_states = wf.waeup_student_wf.states.keys()
21info['wf_states'] = student_wf_states
22info['wf_states'][0] = " ----- "
[565]23mtool = context.portal_membership
24member = mtool.getAuthenticatedMember()
[584]25lt = context.portal_layouts
26pr = context.portal_registration
[565]27path_info = request.get('PATH_INFO').split('/')
28roles = member.getRoles()
[584]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 ',
[587]34        'search_string': ''
[584]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')
[572]55if state == " ----- ":
56    state = ''
[587]57if not term and what in ('student_edit','jamb_id','name','matric_no'):
58    return context.students_manager_view(rendered = rend,
59                             psm = "You must specify a search string",
60                             #psm = "%s, %s" % (psm,ds),
61                             students = items,
62                             is_manager = is_manager,
63                             )
[584]64onlyreview = state and what == "review_state"
[572]65items = []
66res = []
67portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']}
68if onlyreview:
69    res = catalog(portal_type=portal_type_query,
70                  review_state=state)
[584]71elif what == "student_id":
[572]72    res = catalog(portal_type='Student',
[587]73                  id = term.strip())
[584]74elif what == "jamb_id":
[572]75    res = catalog(portal_type='StudentApplication',
[584]76                  SearchableText="%s*" % term.strip().lower())
77elif what == "matric_no":
[572]78    res = catalog(portal_type='StudentClearance',
[584]79                  SearchableText="%s*" % term.strip().lower())
80elif what == "name":
[572]81    res = catalog(portal_type=portal_type_query,
[584]82                  SearchableText="%s*" % term.strip())
[572]83if res:
84    for r in res:
85        row = {}
86        if r.portal_type in ("StudentApplication","StudentPersonal"):
87            items.append(r.getObject().aq_parent)
88        else:
89            items.append(r.getObject())
[584]90students = []
91if items:
92    for item in items:
93        students.append(context.getStudentInfo(item))
94return context.students_manager_view(rendered = rend,
95                             psm = "%d matching Students found" % len(items),
96                             #psm = "%s, %s" % (psm,ds),
97                             students = students,
98                             is_manager = is_manager,
99                             )
Note: See TracBrowser for help on using the repository browser.