Index: WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt	(revision 1117)
+++ WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt	(revision 1120)
@@ -25,14 +25,10 @@
               />
         <br />
-        
-        
-
         <h3><span tal:replace="info/nr_used" /> Pins used out of 
         <span tal:replace="info/batch_doc/no_of_pins" /></h3>
-      
         <span tal:replace="structure rendered" />
-
         <table>
           <tr tal:repeat="pin info/used">
+            <td tal:content="python:path('repeat/pin/index')+1" />
             <td width="50px"> <span tal:content="pin/serial" />: </td>
             <td tal:content="pin/pin" />
@@ -45,8 +41,5 @@
           </tr>
         </table>
-
-
         <br />
-
         <span tal:condition="python:member.id in ('admin','joachim')">        
         ---top secret---
@@ -59,6 +52,4 @@
         ---top secret---
         </span>        
-        
-        
       </span>
     </metal:main>
Index: WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py	(revision 1117)
+++ WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py	(revision 1120)
@@ -20,4 +20,52 @@
 #from Products.zdb import set_trace
 #set_trace()
+def set_used_pins(items, from_cat=False):
+    l = []
+    for i in items:
+        item = {}
+        if from_cat:
+            sno = i.student
+            prefix = i.prefix_batch
+            serial = i.serial
+            pin = i.pin
+        else:
+            sno = i['student']
+            prefix = i.get('prefix_batch')
+            serial = i.get('serial')
+            pin = i.get('pin')
+        item['student'] = sno
+        item['prefix'] = prefix 
+        item['serial'] = serial
+        if len(sno) > 0:
+            item['pin'] = pin
+        else:
+            if str(member) in ('henrik','joachim'):
+                item['pin'] = "%s" % (pin,)
+            else:
+                item['pin'] = "%s%s****%s" % (i.prefix_batch,pin[-10:-7],pin[-3:])
+        if len(sno)==10:
+            #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
+            res = context.students_catalog(jamb_reg_no=sno.upper())
+            if len(res) > 0:
+                if sno.startswith('disabled'):
+                    item['student_url'] = None
+                else:
+                    item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
+                item['student_id'] = res[0].id
+            else:
+                item['student_url'] = None
+                item['student_id'] = ''
+        elif sno:
+            if sno.startswith('disabled'):
+                item['student_url'] = None
+            else:
+                item['student_url'] = '%s/campus/students/%s' % (context.portal_url(),item['student'])
+            item['student_id'] = item['student']
+        else:
+            item['student_url'] = ''
+            item['student_id'] = "not used"
+        l.append(item)
+    return l
+
 lt = context.portal_layouts
 validate = request.has_key("cpsdocument_edit_button")
@@ -36,4 +84,5 @@
 if context.portal_type == "ScratchCardBatch":
     info['batch_doc'] = context.getContent() 
+    info['used'] = set_used_pins(info['batch_doc'].getUsedPins())
     info['unused'] = info['batch_doc'].getUnusedPins()
     info['nr_used'] = info['batch_doc'].getNumberOfUsedPins()
@@ -68,47 +117,7 @@
     else:
         items = []
-    l = []
 ##  students_url = "%s/%s" % (context.portal_url(),'students')
-    pins = []
-    for i in items:
-        item = {}
-        sno = i['student']
-        item['student'] = sno
-        item['prefix'] = i.prefix_batch
-        item['serial'] = i.serial
-        if len(sno) > 0:
-            item['pin'] = i.pin
-        else:
-            if str(member) in ('henrik','joachim'):
-                item['pin'] = "%s" % (i.pin,)
-            else:
-                item['pin'] = "%s%s****%s" % (i.prefix_batch,i.pin[-10:-7],i.pin[-3:])
-        if i.pin in pins:
-            continue
-        pins.append(i.pins)
-        if len(sno)==10:
-            #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
-            res = context.students_catalog(jamb_reg_no=sno.upper())
-            if len(res) > 0:
-                if sno.startswith('disabled'):
-                    item['student_url'] = None
-                else:
-                    item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
-                item['student_id'] = res[0].id
-            else:
-                item['student_url'] = None
-                item['student_id'] = ''
-        elif sno:
-            if sno.startswith('disabled'):
-                item['student_url'] = None
-            else:
-                item['student_url'] = '%s/campus/students/%s' % (context.portal_url(),item['student'])
-            item['student_id'] = item['student']
-        else:
-            item['student_url'] = ''
-            item['student_id'] = "not used"
-        l.append(item)
         
-    info['used'] = l
+info['used'] = set_used_pins(items,from_cat=True)
 
 return view(rendered = rend,
