##parameters=REQUEST # $Id: apply_admission.py 173 2005-11-15 16:28:29Z joachim $ """ process the Application Form return html renderer + psm """ import DateTime current = DateTime.DateTime() type_name = 'StudentApplication' ti = context.portal_types[type_name] REQUEST.set('type_name',type_name) validate = REQUEST.has_key("cpsdocument_create_button") lt = context.portal_layouts pr = context.portal_registration res,psm,ds = lt.renderLayout(layout_id= 'student_check_pin', schema_id= 'student_check_pin', context=context, mapping=validate and REQUEST, ob={}, layout_mode='create', formaction = "apply_admission", submit = "check", ) if psm == 'invalid': return context.application_pin_form(rendered = res, #psm = "Please correct your input", psm = "psm : #%s#" % (psm,), firstlayout = True, lastlayout = True, ds = ds, ) elif psm == '': return context.application_pin_form(rendered = res, psm = None, firstlayout = True, lastlayout = True, ds = ds, ) elif psm == 'valid': jamb_id = ds.get('jamb_reg_no') catalog = context.portal_catalog search = catalog({'meta_type': 'StudentApplication', 'jamb_reg_no': jamb_id }) if len(search) < 1: psm = "No JAMB record %s" % (jamb_id) return context.application_pin_form(rendered = res, psm = psm, ds = ds, ) application = search[0].getObject() student = application.aq_parent if context.portal_workflow.getInfoFor(student,'review_state',None) == "created": student.invokeFactory('StudentClearance','clearance') student.invokeFactory('StudentPersonal','personal') student.content_status_modify(workflow_action="enter_application_pin") apdoc = application.getContent() names = apdoc.jamb_lastname.split() dp = {} if len(names) == 3: dp['firstname'] = names[0].capitalize() dp['middlename'] = names[1].capitalize() dp['lastname'] = names[2].capitalize() elif len(names) == 2: dp['firstname'] = names[0].capitalize() dp['lastname'] = names[1].capitalize() else: dp['lastname'] = apdoc.jamb_lastname dp['sex'] = apdoc.jamb_sex == 'M' dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga ) student.personal.getContent().edit(mapping = dp) da = {} da['app_ac_pin'] = ds['pin'] apdoc.edit(mapping = da) # now display the passport form with jamb-data readonly return student.application_form()