##parameters=REQUEST # $Id: start_clearance.py 1571 2007-03-17 15:25:56Z henrik $ """ request Clearance """ import DateTime current = DateTime.DateTime() pr = context.portal_registration import logging logger = logging.getLogger('Skins.start_clearance') #type_name = 'Student' #ti = context.portal_types[type_name] #request.set('type_name',type_name) wf = context.portal_workflow request=REQUEST redirect = request.RESPONSE.redirect validate = REQUEST.has_key("cpsdocument_create_button") lt = context.portal_layouts #pr = context.portal_registration info = context.getClearanceInfo() 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, info = info, ) 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'])) if 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'])) 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 started clearance without passport picture' % (info['id'])) if error: return context.clearance_pin_form(rendered = res, psm = psm, firstlayout = True, lastlayout = True, ds = ds, info = info, ) 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) if info['penalty']: logger.info('%s started late clearance' % (info['id'])) return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())