## Script (Python) "logged_in" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## """Prepare user login modified from cps_default/logged_in.py $Id: logged_in.py 1417 2007-02-15 10:56:43Z joachim $ """ import DateTime current = DateTime.DateTime() import logging logger = logging.getLogger('Member.Login') from urllib import unquote request = context.REQUEST response = request.RESPONSE utool = context.portal_url mtool = context.portal_membership wftool = context.portal_workflow portal = utool.getPortalObject() redirect_to_portal = False is_anon = mtool.isAnonymousUser() member = mtool.getAuthenticatedMember() load_passport = hasattr(context.waeup_tool,'loadStudentFoto') if not is_anon: if "Student" in member.getRoles(): to_waeup_student_home = True students = context.portal_url.getPortalObject().campus.students student = getattr(students,str(member)) student_app = getattr(student,'application',None) if request.has_key('returning') and student_app is None: email=request.get("email") phone=request.get("phone_nr") context.waeup_tool.makeStudentData(str(member), email=email, phone_nr=phone, ) d = {} d['id'] = str(member) d['email'] = email d['phone'] = phone context.students_catalog.modifyRecord(**d) elif student_app is None: context.waeup_tool.makeStudentData(str(member)) student_app = getattr(student,'application',None) if 'payments' not in student.objectIds(): student.invokeFactory('PaymentsFolder','payments') payments = getattr(student,'payments') wftool.doActionFor(payments,'open') d = {} d['Title'] = 'Online Payments' payments.getContent().edit(mapping=d) student_pume = getattr(student,'pume',None) s_review_state = wftool.getInfoFor(student,'review_state',None) a_review_state = wftool.getInfoFor(student_app,'review_state',None) student_per = getattr(student,'personal',None) p_review_state = wftool.getInfoFor(student_per,'review_state',None) logger.info('"%s", "logged in", "review_state %s"' % (member,s_review_state)) app_doc = student_app.getContent() #from Products.zdb import set_trace;set_trace() if load_passport and 'passport' not in app_doc.objectIds(): msg = context.waeup_tool.loadStudentFoto(student) logger.info('"%s", "%s"' % (member,msg)) if s_review_state in ("student_created","admitted") and\ a_review_state == 'created' : wftool.doActionFor(student_app,'open') if student_pume is not None: wftool.doActionFor(student_pume,'close') da = {} pin = request.get('pin') if not pin: jamb_reg_no = app_doc.jamb_reg_no for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()): res = context.portal_pins(student=reg_no) if len(res) > 0: break if len(res) > 0: p = res[0].pin if len(p) > 10: pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:]) else: pin = p da['app_ac_pin'] = pin da['app_ac_date'] = current app_doc.edit(mapping = da) elif s_review_state in ("admitted") and a_review_state == 'opened' and\ not app_doc.app_ac_pin: jamb_reg_no = app_doc.jamb_reg_no for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()): res = context.portal_pins(student=reg_no) if len(res) > 0: break if len(res) > 0: p = res[0].pin if len(p) > 10: pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:]) else: pin = p da = {} da['app_ac_pin'] = pin app_doc.edit(mapping = da) elif s_review_state in ("cleared_and_validated",) and\ p_review_state == 'created' : wftool.doActionFor(student_per,'open') res = context.students_catalog(id = str(member)) matric_no = res[0].matric_no is_imported = context.returning_import(matric_no = matric_no) if s_review_state == "application_pin_entered": redirect_url = "%s/application_edit_form" % student.absolute_url() elif s_review_state in ('admitted', 'objection_raised',): redirect_url = "%s/admission_form" % student.absolute_url() elif s_review_state == "clearance_pin_entered": redirect_url = "%s/clearance_edit_form" % student.absolute_url() elif s_review_state == "cleared_and_validated": redirect_url = "%s/personal_edit_form" % student.absolute_url() elif s_review_state == "returning" and is_imported: redirect_url = "%s/session_results_view" % student.absolute_url() else: redirect_url = "%s/student_index" % student.absolute_url() else: logger.info('"%s", "logged in"' % (member)) redirect_url = portal.absolute_url() #Anonymous else: response.expireCookie('__ac', path='/') return context.user_logged_in_failed() # Setup skins if (getattr(utool, 'updateSkinCookie', False) and utool.updateSkinCookie()): context.setupCurrentSkin() response.redirect(redirect_url)