##parameters=REQUEST # $Id: start_clearance.py 1108 2006-12-20 22:13:36Z henrik $ """ request Clearance """ import DateTime current = DateTime.DateTime() pr = context.portal_registration import logging logger = logging.getLogger('Student.Clearance.Start') type_name = 'Student' request=REQUEST 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 info = context.getStudentInfo() if info is None: member_id = str(context.portal_membership.getAuthenticatedMember()) logger.info('"%s","tried to start clearance for", "%s"' % (member_id,request.get('PATH_INFO').split('/')[-2])) return redirect("%s/srp_invalid_access" % context.portal_url()) app_doc = info['app_doc'] review_state = info['review_state'] session = REQUEST.SESSION 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", ) if psm == '': return context.clearance_pin_form(rendered = res, psm = None, firstlayout = True, lastlayout = True, ds = ds, ) error = False if session.get("clicked",None): psm = 'Please wait a moment until "Clearance started" turns green, then click on the green link!' error = True logger.info('"%s","repeatedly pressed the clearance button"' % (info['id'])) elif app_doc.passport is None: psm = "You must upload your passport picture before you can start the registration process!" error = True logger.info('"%s", "tried to start clerance without passport picture"' % (info['id'])) elif review_state == "clearance_pin_entered": psm = "You have already entered a clearance pin!" error = True logger.info('"%s", "tried to start clearance though already started"' % (info['id'])) elif psm == 'invalid': psm = "Please correct your input!" error = True logger.info('"%s","entered wrong clearance pin"' % (info['id'])) if error: return context.clearance_pin_form(rendered = res, psm = psm, firstlayout = True, lastlayout = True, ds = ds, ) session.set("clicked","clicked") pin = str(ds.get('clr_ac_pin')) logger.info('"%s", "started clearance with pin", "%s"' % (info['id'],pin)) wf.doActionFor(info['student'],'enter_clearance_pin') wf.doActionFor(info['clear'],'open') dc = {} app_doc = info['app_doc'] dc['lga_ident'] = app_doc.get('jamb_lga') dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga') dc['clr_ac_pin'] = pin dc['clr_ac_date'] = current dc['entry_date'] = current dc['entry_session'] = "2006/2007" wf.doActionFor(info['app'],'close') info['clear_doc'].edit(mapping = dc) return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())