##parameters=REQUEST,matric_no # $Id: set_access_data.py 1177 2007-01-02 15:02:02Z joachim $ """ process the Application Form return html renderer + psm """ import DateTime,logging current = DateTime.DateTime() pr = context.portal_registration logger = logging.getLogger('Returning') validate = REQUEST.has_key("cpsdocument_edit_button") lt = context.portal_layouts #pr = context.portal_registration default = {'matric_no':matric_no} st_res = context.students_catalog(matric_no = matric_no) if st_res: sid = st_res[0].id else: logger.info('"%s","Studentobject does not exist"' % matric_no) res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search', schema_id= 'student_returning', context=context, mapping=validate and REQUEST, ob=default, layout_mode='edit', formaction = "set_access_data", button = "Search", matric_no = matric_no, commit = False, ) if psm == '': return context.set_access_data_form(rendered = res, psm = None, firstlayout = True, lastlayout = True, ds = ds, name = "%(name)s" % REQUEST.form ) elif psm == 'invalid': psm = "Please correct your input!" elif psm == 'valid' and not REQUEST.form.has_key('acknowledge'): psm = "You did not check the ackkowledge box !" else: psm = '' if psm != '': return context.set_access_data_form(rendered = res, #psm = "%s, %s" % (psm,ds), psm = psm, firstlayout = True, lastlayout = True, ds = ds, name = "%(name)s" % REQUEST.form ) password = REQUEST.get('widget__password') email = ds.get('email') context.waeup_tool.makeStudentMember(sid,password=password) args = {} args['__ac_name'] = sid args['__ac_password'] = password args['returning'] = '1' args['email'] = email args['phone_nr'] = ds.get('phone_nr') from urllib import urlencode url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) return REQUEST.RESPONSE.redirect(url)