Index: /WAeUP_SRP/trunk/ScratchCards.py
===================================================================
--- /WAeUP_SRP/trunk/ScratchCards.py	(revision 1001)
+++ /WAeUP_SRP/trunk/ScratchCards.py	(revision 1002)
@@ -136,14 +136,14 @@
               } for p in pins_cat.searchResults(prefix_batch = "%s%d"
                                                % (doc.prefix,doc.batch_no),
-                                               ) if not p.student]
-        used = [{'pin': p.pin,
-              'serial': p.serial,
-              'student': p.student,
-              } for p in pins_cat.searchResults(prefix_batch = "%s%d"
-                                               % (doc.prefix,doc.batch_no),
-                                               ) if p.student]
-        if len (unused) <= max_pins:
-            return unused,used
-        return unused[:max_pins],used
+                                               )[-max_pins:] if not p.student]
+##        used = [{'pin': p.pin,
+##              'serial': p.serial,
+##              'student': p.student,
+##              } for p in pins_cat.searchResults(prefix_batch = "%s%d"
+##                                               % (doc.prefix,doc.batch_no),
+##                                               ) if p.student]
+##        if len (unused) <= max_pins:
+##            return unused,used
+        return unused
 
 InitializeClass(ScratchCardBatch)
Index: /WAeUP_SRP/trunk/profiles/default/layouts.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 1001)
+++ /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 1002)
@@ -13,4 +13,5 @@
  <object name="student" meta_type="CPS Layout"/>
  <object name="scratch_card_batch" meta_type="CPS Layout"/>
+ <object name="scratch_card_search" meta_type="CPS Layout"/>
  <object name="student_study_course" meta_type="CPS Layout"/>
  <object name="student_accommodation" meta_type="CPS Layout"/>
Index: /WAeUP_SRP/trunk/profiles/default/layouts/scratch_card_search.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/scratch_card_search.xml	(revision 1002)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/scratch_card_search.xml	(revision 1002)
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<object name="scratch_card_search" meta_type="CPS Layout">
+ <property name="layout_create_method"></property>
+ <property name="layout_edit_method"></property>
+ <property name="layout_view_method"></property>
+ <property name="style_prefix">layout_search_</property>
+ <property name="flexible_widgets"/>
+ <property name="validate_values_expr"></property>
+ <property name="label"></property>
+ <property name="label_edit"></property>
+ <property name="is_i18n">False</property>
+ <widget name="search_mode" meta_type="Generic Select Widget">
+  <property name="title">Search Mode</property>
+  <property name="fields">
+   <element value="search_mode"/>
+  </property>
+  <property name="is_required">True</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="vocabulary">scratch_card_search_mode</property>
+  <property name="render_format">radio</property>
+ </widget>
+ <widget name="search_string" meta_type="String Widget">
+  <property name="title">Search String</property>
+  <property name="fields">
+   <element value="search_string"/>
+  </property>
+  <property name="label">complete ids only</property>
+  <property name="label_edit">complete ids only</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <table>
+  <row>
+   <cell name="search_mode"/>
+   <cell name="search_string"/>
+  </row>
+ </table>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/vocabularies.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/vocabularies.xml	(revision 1001)
+++ /WAeUP_SRP/trunk/profiles/default/vocabularies.xml	(revision 1002)
@@ -21,4 +21,5 @@
  <object name="pin_prefixes" meta_type="CPS Vocabulary"/>
  <object name="student_search_mode" meta_type="CPS Vocabulary"/>
+ <object name="scratch_card_search_mode" meta_type="CPS Vocabulary"/>
  <object name="student_status_voc" meta_type="CPS Vocabulary"/>
  <object name="searchable_student_states" meta_type="CPS Vocabulary"/>
Index: /WAeUP_SRP/trunk/profiles/default/vocabularies/scratch_card_search_mode.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/vocabularies/scratch_card_search_mode.xml	(revision 1002)
+++ /WAeUP_SRP/trunk/profiles/default/vocabularies/scratch_card_search_mode.xml	(revision 1002)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<object name="search_mode_voc" meta_type="CPS Vocabulary">
+ <property name="title"></property>
+ <property name="title_msgid"></property>
+ <property name="description"></property>
+ <property name="acl_write_roles">Manager</property>
+ <item key="student" msgid="">Student/Jamb Id</item>
+ <item key="pin" msgid="">Pin</item>
+</object>
Index: /WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt	(revision 1001)
+++ /WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt	(revision 1002)
@@ -1,7 +1,7 @@
-<metal:html tal:define="info context/getBatchInfo;
+<metal:html tal:define="info options/info;
+                        rendered options/rendered;
                         mtool here/portal_membership;
                         member mtool/getAuthenticatedMember;
                         ">
-
   <metal:body use-macro="here/main_template/macros/master">
     <metal:block fill-slot="header">
@@ -29,5 +29,5 @@
         <h3>Unused</h3>
         <table>
-          <tr tal:repeat="pin info/unused">
+          <tr tal:repeat="pin python: info['unused'][:2]">
             <td width="50px"> <span tal:content="pin/serial" />: </td>
             <td tal:content="pin/pin" />
@@ -35,10 +35,12 @@
         </table>
         </span>
+        <span tal:replace="structure rendered" />
 
-        <h3>Used</h3>
+        <h3>Results</h3>
         <table>
           <tr tal:repeat="pin info/used">
             <td width="50px"> <span tal:content="pin/serial" />: </td>
             <td tal:content="pin/pin" />
+            <td tal:content="pin/student_id" />
             <td>
               <a tal:condition="pin/student_url" href="" tal:content="pin/student"
Index: /WAeUP_SRP/trunk/skins/waeup_pins/getBatchInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_pins/getBatchInfo.py	(revision 1001)
+++ /WAeUP_SRP/trunk/skins/waeup_pins/getBatchInfo.py	(revision 1002)
@@ -25,6 +25,6 @@
 info['unused'],used = batch.getContent().getUnusedPins()
 l = []
-students_rpath = context.portal_catalog(meta_type = "StudentsFolder")[-1].relative_path
-students_url = "%s/%s" % (context.portal_url(),students_rpath)
+p_url = context.portal_url
+students_url = "%s/%s" % (p_url,"students")
 
 for item in used:
@@ -32,11 +32,14 @@
     if len(sno)==10:
     #if bd.prefix == "APP":
-        res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
+        #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
+        res = context.students_catalog(jamb_reg_no=sno)
         if len(res) > 0:
-            item['student_url'] = "%s/%s" % (context.portal_url(),res[0].relative_path)
+            item['student_url'] = "%s/%s" % (context.portal_url(),res[0].id)
+            item['student_id'] = res[0].id
         else:
             item['student_url'] = None
     else:
         item['student_url'] = '%s/%s' % (students_url,item['student'])
+        item['student_id'] = student
 info['used'] = used
 return info
Index: /WAeUP_SRP/trunk/skins/waeup_pins/pins_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_pins/pins_view.pt	(revision 1001)
+++ /WAeUP_SRP/trunk/skins/waeup_pins/pins_view.pt	(revision 1002)
@@ -10,5 +10,5 @@
           <tr tal:repeat="batch batches">
             <td><a href="batch" 
-                   tal:attributes="href string:${batch/getPath}"
+                   tal:attributes="href string:${batch/getPath}/search_pins"
                    tal:content="batch/Title"></a></td>    
           </tr>
Index: /WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py	(revision 1002)
+++ /WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py	(revision 1002)
@@ -0,0 +1,84 @@
+## Script (Python) "search_pins"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST
+##title=
+##
+# $Id: search_students.py 911 2006-11-20 15:11:29Z henrik $
+"""
+list Students for ClearanceOfficers
+"""
+request = REQUEST
+wftool = context.portal_workflow
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+roles = member.getRolesInContext(context)
+#from Products.zdb import set_trace
+#set_trace()
+lt = context.portal_layouts
+validate = request.has_key("cpsdocument_edit_button")
+rend,psm,ds = lt.renderLayout(layout_id= 'scratch_card_search',
+                      schema_id= 'student_search',
+                      context=context,
+                      mapping=validate and request,
+                      ob={},
+                      layout_mode='edit',
+                      formaction="search_pins",
+                      commit = False,
+                      )
+info = {}
+info['batch_doc'] = context.getContent() 
+info['unused'] = info['batch_doc'].getUnusedPins()
+info['used'] = []
+
+if psm == '':
+    return context.batch_view(rendered = rend,
+                             psm = psm,
+                             #psm = "%s, %s" % (psm,ds),
+                             info = info,
+                             allowed = True,
+                             )
+#set_trace()
+what = ds.get('search_mode')
+term = ds.get('search_string')
+
+if what == 'student':
+    items_2 = context.portal_pins(student = term)
+    items_1 = context.portal_pins(student = term.upper())
+    items = items_1 + items_2
+elif what == 'pin':
+    items = context.portal_pins(pin = term.upper())
+else:
+    items = []
+l = []
+for i in items:
+    item = {}
+    sno = i['student']
+    item['student'] = sno
+    item['serial'] = i.serial
+    item['pin'] = i.pin
+    if len(sno)==10:
+    #if bd.prefix == "APP":
+        #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
+        res = context.students_catalog(jamb_reg_no=sno.upper())
+        if len(res) > 0:
+            item['student_url'] = "%s/%s" % (context.portal_url(),res[0].id)
+            item['student_id'] = res[0].id
+        else:
+            item['student_url'] = None
+            item['student_id'] = ''
+    else:
+        item['student_url'] = '%s/%s' % (students_url,item['student'])
+        item['student_id'] = student
+    l.append(item)
+    
+info['used'] = l
+return context.batch_view(rendered = rend,
+                             psm = psm,
+                             #psm = "%s, %s" % (psm,ds),
+                             info = info,
+                             allowed = True,
+                             )
