##parameters=REQUEST # $Id: check_admission.py 173 2005-11-15 16:28:29Z joachim $ """ process the Admission Form return html renderer + psm """ import DateTime current = DateTime.DateTime() type_name = 'Jamb' ti = context.portal_types[type_name] REQUEST.set('type_name',type_name) validate = REQUEST.has_key("cpsdocument_edit_button") lt = context.portal_layouts pr = context.portal_registration res,psm,ds = lt.renderLayout(layout_id= 'admission', schema_id= 'student_admission', context=context, mapping=validate and REQUEST, ob={}, layout_mode='create', action = "check_admission", submit = "check", ) if psm == 'invalid': return context.check_admission_form(rendered = res, psm = "Please correct your input", ds = ds, ) elif psm == '': return context.check_admission_form(rendered = res, psm = None, ds = ds, ) elif psm == 'valid': s_id = "s%s" % ds.get('jamb_id') catalog = context.portal_catalog search = catalog(SearchableText = "%s*" % s_id) student = getattr(context,s_id,None) if student is None: #if len(search) < 1: psm = "Your are not admitted" return context.check_admission_form(rendered = res, psm = psm, ds = ds, ) ds.set('sc_date',current) student.getContent().setScratchCardData('adm_check',ds) jamb = getattr(student,'JAMB') res = jamb.getContent().render(layout_id = 'admission_slip', layout_mode = 'view', schema_id = 'jamb') return context.admission_slip_form(rendered = res, dict = ds)