##parameters=REQUEST # $Id: apply_admission.py 488 2006-09-07 12:34:56Z 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_application_fe', schema_id= 'student_application', 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 = "%s, %s" % (psm,ds), 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') student = context.getContent().getStudentByRegNo(jamb_id) if student is None: psm = "JAMB record %s not accessible." % (jamb_id) return context.application_pin_form(rendered = res, psm = psm, #psm = "%s, %s" % (psm,ds), ds = ds, ) application = student.application 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 == 'F' dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga ) student.personal.getContent().edit(mapping = dp) da = {} da['app_ac_pin'] = ds.get('app_ac_pin') da['app_ac_date'] = current apdoc.edit(mapping = da) # now display the passport form with jamb-data readonly return context.REQUEST.RESPONSE.redirect("%s/application_form" % (student.application.absolute_url())) return student.application_form()