## Script (Python) "getSchoolFeePrefix" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: getSchoolFeePrefix.py 5062 2010-03-15 08:02:01Z henrik $ """ return the Prefix for Schoolfee """ if context.portal_membership.isAnonymousUser(): return None try: from Products.zdb import set_trace except: def set_trace(): pass import logging logger = logging.getLogger('Skins.getSchoolFeePrefix') student_id = context.getStudentId() student_record = context.students_catalog(id=student_id)[0] FRNART = ( "BADTSW", "BAEDEDO", "BAEDEL", "BAEDENG", "BAEDFAA", "BAEDFRC", "BAEDHIS", "BBEDSW", "BECOSW", "BEDADT", "BEMGTSW", "BENLSW", "BGEOSW", "BHISSW", "BPOLSW", "BSCEDAC", "BSCEDAP", "BSCEDB", "BSCEDBE", "BSCEDE", "BSCEDECO", "BSCEDES", "BSCEDG", "BSCEDGEO", "BSCEDGR", "BSCEDPOL", "BSCEDPS", "BSCEDSE", "BSCEDSOC", "BSCEDSS", "BSSTSW", "DAED", ) FRNSCI = ( "BAGRSW", "BBIOSW", "BCHESW", "BCSCSW", "BHECSW", "BHEDSW", "BISCSW", "BITESW", "BSCEDAG", "BSCEDBC", "BSCEDC", "BSCEDCO", "BSCEDEE", "BSCEDEM", "BSCEDEV", "BSCEDHE", "BSCEDHK", "BSCEDHM", "BSCEDIS", "BSCEDM", "BSCEDME", "BSCEDP", "BSCEDPE", "BSCEDTE", "BSCEDWB", "DHT", ) if student_record.lga == 'foreigner': if student_record.course in FRNART: prefix == 'FRNART' elif student_record.course in FRNSCI: prefix == 'FRNSCI' else: logger.info('%s, foreign student course %s not categorized' % (student_id,student_record.faculty)) prefix = "--" return prefix if student_record.review_state == 'cleared_and_validated': prefix = prefix + 'NEW' return prefix res = context.certificates_catalog(code = student_record.course) if not res: logger.info('%s, certificate %s not found' % (student_id,student_record.course)) prefix = "--" else: prefix = res[0].school_fee_code if not prefix or prefix == 'none': prefix = res[0].faculty if student_record.review_state == 'cleared_and_validated': prefix = prefix + 'NEW' return prefix