source: WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py @ 1005

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

search for PIN added

File size: 2.6 KB
Line 
1## Script (Python) "search_pins"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST
8##title=
9##
10# $Id: search_students.py 911 2006-11-20 15:11:29Z henrik $
11"""
12list Students for ClearanceOfficers
13"""
14request = REQUEST
15wftool = context.portal_workflow
16mtool = context.portal_membership
17member = mtool.getAuthenticatedMember()
18roles = member.getRolesInContext(context)
19#from Products.zdb import set_trace
20#set_trace()
21lt = context.portal_layouts
22validate = request.has_key("cpsdocument_edit_button")
23rend,psm,ds = lt.renderLayout(layout_id= 'scratch_card_search',
24                      schema_id= 'student_search',
25                      context=context,
26                      mapping=validate and request,
27                      ob={},
28                      layout_mode='edit',
29                      formaction="search_pins",
30                      commit = False,
31                      )
32info = {}
33info['batch_doc'] = context.getContent()
34info['unused'] = info['batch_doc'].getUnusedPins()
35info['used'] = []
36
37if psm == '':
38    return context.batch_view(rendered = rend,
39                             psm = psm,
40                             #psm = "%s, %s" % (psm,ds),
41                             info = info,
42                             allowed = True,
43                             )
44#set_trace()
45what = ds.get('search_mode')
46term = ds.get('search_string')
47
48if what == 'student':
49    items_2 = context.portal_pins(student = term)
50    items_1 = context.portal_pins(student = term.upper())
51    items = items_1 + items_2
52elif what == 'pin':
53    items = context.portal_pins(pin = term.upper())
54else:
55    items = []
56l = []
57for i in items:
58    item = {}
59    sno = i['student']
60    item['student'] = sno
61    item['serial'] = i.serial
62    item['pin'] = i.pin
63    if len(sno)==10:
64    #if bd.prefix == "APP":
65        #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
66        res = context.students_catalog(jamb_reg_no=sno.upper())
67        if len(res) > 0:
68            item['student_url'] = "%s/%s" % (context.portal_url(),res[0].id)
69            item['student_id'] = res[0].id
70        else:
71            item['student_url'] = None
72            item['student_id'] = ''
73    else:
74        item['student_url'] = '%s/%s' % (students_url,item['student'])
75        item['student_id'] = student
76    l.append(item)
77   
78info['used'] = l
79return context.batch_view(rendered = rend,
80                             psm = psm,
81                             #psm = "%s, %s" % (psm,ds),
82                             info = info,
83                             allowed = True,
84                             )
Note: See TracBrowser for help on using the repository browser.