##parameters=REQUEST # $Id: start_clearance.py 892 2006-11-18 21:14:18Z henrik $ """ request Clearance """ import DateTime current = DateTime.DateTime() pr = context.portal_registration type_name = 'Student' ti = context.portal_types[type_name] REQUEST.set('type_name',type_name) redirect = REQUEST.RESPONSE.redirect wf = context.portal_workflow validate = REQUEST.has_key("cpsdocument_create_button") lt = context.portal_layouts pr = context.portal_registration res,psm,ds = lt.renderLayout(layout_id='student_clearance', schema_id= 'student_clearance', context=context, mapping=validate and REQUEST, ob={}, layout_mode='create', formaction = "start_clearance", button = "Start", ) info = context.getStudentInfo() app_doc = info['app_doc'] if app_doc.passport is None: return context.clearance_pin_form(rendered = res, psm = "You must upload your passport picture before you can start the registration process!", #psm = "%s, %s" % (psm,ds), firstlayout = True, lastlayout = True, ds = ds, ) if psm == 'invalid': return context.clearance_pin_form(rendered = res, psm = "Please correct your input!", #psm = "%s, %s" % (psm,ds), firstlayout = True, lastlayout = True, ds = ds, ) elif psm == '': return context.clearance_pin_form(rendered = res, psm = None, firstlayout = True, lastlayout = True, ds = ds, ) elif psm == 'valid': info = context.getStudentInfo() review_state = info['review_state'] wf.doActionFor(info['student'],'enter_clearance_pin') wf.doActionFor(info['app'],'close') wf.doActionFor(info['clear'],'open') pin = str(ds.get('clr_ac_pin')) dc = {} dc['clr_ac_pin'] = pin dc['clr_ac_date'] = current dc['entry_date'] = current dc['entry_session'] = "2006/2007" info['clear_doc'].edit(mapping = dc) return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())