## 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 845 2006-11-11 21:29:50Z henrik $ """ 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 = [] students_rpath = context.portal_catalog(meta_type = "StudentsFolder")[-1].relative_path students_url = "%s/%s" % (context.portal_url(),students_rpath) for item in used: sno = item['student'] if len(sno)==10: #if bd.prefix == "APP": res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication') if len(res) > 0: item['student_url'] = "%s/%s" % (context.portal_url(),res[0].relative_path) else: item['student_url'] = None else: item['student_url'] = '%s/%s' % (students_url,item['student']) info['used'] = used return info