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

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

student_search fixed for ClearanceOfficers?
getStudentInfo checks for access to not owned Student-Ids and logs them.
search Pins shows all used PIN's

File size: 2.9 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"""
14
15request = REQUEST
16wftool = context.portal_workflow
17mtool = context.portal_membership
18member = mtool.getAuthenticatedMember()
19roles = member.getRolesInContext(context)
20#from Products.zdb import set_trace
21#set_trace()
22lt = context.portal_layouts
23validate = request.has_key("cpsdocument_edit_button")
24rend,psm,ds = lt.renderLayout(layout_id= 'scratch_card_search',
25                      schema_id= 'student_search',
26                      context=context,
27                      mapping=validate and request,
28                      ob={},
29                      layout_mode='edit',
30                      formaction="search_pins",
31                      commit = False,
32                      )
33info = {}
34info['batch_doc'] = context.getContent()
35info['unused'] = info['batch_doc'].getUnusedPins()
36info['used'] = []
37
38if psm == '':
39    return context.batch_view(rendered = rend,
40                             psm = psm,
41                             #psm = "%s, %s" % (psm,ds),
42                             info = info,
43                             allowed = True,
44                             )
45#set_trace()
46what = ds.get('search_mode')
47term = ds.get('search_string')
48
49if what == 'student':
50    items_1 = context.portal_pins(student = term.upper())
51    items_2 = context.portal_pins(student = term.lower())
52    items = items_1 + items_2
53elif what == 'pin':
54    items = context.portal_pins(pin = term.upper())
55else:
56    items = []
57l = []
58students_url = "%s/%s" % (context.portal_url(),'students')
59pins = []
60for i in items:
61    item = {}
62    sno = i['student']
63    item['student'] = sno
64    item['serial'] = i.serial
65    item['pin'] = i.pin
66    if i.pin in pins:
67        continue
68    pins.append(i.pins)
69    if len(sno)==10:
70        #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
71        res = context.students_catalog(jamb_reg_no=sno.upper())
72        if len(res) > 0:
73            item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
74            item['student_id'] = res[0].id
75        else:
76            item['student_url'] = None
77            item['student_id'] = ''
78    elif sno:
79        item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
80        item['student_id'] = student
81    else:
82        item['student_url'] = ''
83        item['student_id'] = "not used"
84    l.append(item)
85   
86info['used'] = l
87return context.batch_view(rendered = rend,
88                             psm = psm,
89                             #psm = "%s, %s" % (psm,ds),
90                             info = info,
91                             allowed = True,
92                             )
Note: See TracBrowser for help on using the repository browser.