## Script (Python) "getBatchInfo"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=batch=None
##title=
##
# $Id: getBatchInfo.py 1002 2006-12-06 18:08:45Z joachim $
"""
return Info about the current Batch
"""

info = {}
if batch is None:
    if context.portal_type == 'ScratchCardBatch':
        batch = context
    else:
        return None
bd = batch.getContent()
info['batch_doc'] = bd
info['id'] = batch.getId()
info['title'] = batch.Title or 'empty Title'
info['unused'],used = batch.getContent().getUnusedPins()
l = []
p_url = context.portal_url
students_url = "%s/%s" % (p_url,"students")

for item in used:
    sno = item['student']
    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)
        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
    else:
        item['student_url'] = '%s/%s' % (students_url,item['student'])
        item['student_id'] = student
info['used'] = used
return info
