##parameters=REQUEST # $Id: check_admission.py 2407 2007-10-21 06:21:25Z henrik $ """ request Clearance """ import DateTime from urllib import urlencode current = DateTime.DateTime() pr = context.portal_registration type_name = 'StudentApplication' 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") mtool = context.portal_membership is_anon = mtool.isAnonymousUser() member = mtool.getAuthenticatedMember() lt = context.portal_layouts pr = context.portal_registration res,psm,ds = lt.renderLayout('student_application_fe', 'student_application', context, mapping=validate and REQUEST, layout_mode='create', ob={}, commit=False, formaction = "check_admission", button = "Check", ) if psm == 'invalid': return context.check_admission_pin_form(rendered = res, psm = "Please correct your input!", #psm = "%s, %s" % (psm,ds), firstlayout = True, lastlayout = True, ds = ds, ) elif psm == '': return context.check_admission_pin_form(rendered = res, psm = None, firstlayout = True, lastlayout = True, ds = ds, ) elif psm == 'valid': s_id = ds.get('s_id') if is_anon and not s_id: return context.check_admission_pin_form(rendered = res, psm = "You are not allowed to call this form in this context. Please try to log in.", #psm = "%s, %s" % (psm,ds), firstlayout = True, lastlayout = True, ds = ds, ) elif not is_anon: return context.check_admission_pin_form(rendered = res, psm = "You are already logged in!", #psm = "%s, %s" % (psm,ds), firstlayout = True, lastlayout = True, ds = ds, ) ## ## email = ds.get('app_email') student = getattr(context.campus.students, s_id) review_state = wf.getInfoFor(student,'review_state',None) #if review_state == "admission_rejected": # url = "%s/campus/students/%s/pume/admission_rejected_view" % (context.portal_url(),s_id) # return redirect(url) pw = str(ds.get('app_ac_pin_n')) args = {} args['__ac_name'] = s_id #args['__ac_password'] = pin.split('-')[2] args['__ac_password'] = pw args['pin'] = str(ds.get('app_ac_pin_p')) + '-' + str(ds.get('app_ac_pin_b')) + '-' + str(ds.get('app_ac_pin_n')) ## args['email'] = email url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) return redirect(url)