##parameters=REQUEST=None # $Id: eligibility.py 179 2005-11-16 16:44:13Z joachim $ """ process the Admission Form return html renderer + psm """ request = REQUEST rget = request.get rset = request.set fget = request.form.get fhas = request.form.has_key lt = context.portal_layouts pr = context.portal_registration pm = context.portal_membership eli = context.ELIGIBILITY.getContent() sr = eli.schoolresults res,psm,ds = lt.renderLayout(layout_id= 'student_schoolresults', schema_id= 'student_eligibility', context=context, mapping=request, ob={}, layout_mode='create', formaction = "eligibility", schoolresults = sr, ) inr = 0 if fhas('add') and (fget('type') or fget('subject') or fget('result')): sr.append((fget('type'),fget('subject'),fget('result'))) psm = "new result added" elif fhas('change') and fget('keys'): for k in fget('keys'): sr[int(k)] = (fget('type_%s' % k),fget('subject_%s' % k),fget('result_%s' % k)) inr += 1 psm = "%s items changed" % inr elif fhas('delete') and fget('keys'): new = [] todelete = fget('keys') for k in range(len(sr)): if str(k) not in todelete: new.append(sr[k]) inr = len(todelete) sr = new psm = "%s items deleted" % inr else: psm = '' eli.edit(mapping={'schoolresults': sr}) res,dummy,ds = lt.renderLayout(layout_id= 'student_schoolresults', schema_id= 'student_eligibility', context=context, mapping=request, ob={}, layout_mode='create', formaction = "eligibility", schoolresults = sr, ) return context.eligibility_form(rendered = res, #psm = str(ds), psm = psm, ) ##elif psm == '': ## return context.eligibility_form(rendered = res, ## psm = None, ## ds = ds, ## ) ##elif psm == 'valid': ## s_personal = context.PERSONAL.getContent() ## s_personal.edit(mapping={'email': ds.get('email')}) ## #pw = REQUEST.get("widget__pw") ## #pm.setPassword(pw) ##psm = 'Email has been successfully set.' ##return context.REQUEST.RESPONSE.redirect('%s' % context.portal_url.getUrlFromRpath('/students')) ## ####return context.eligibility_form(rendered = res, #### psm = psm, #### ds = ds, #### )