## 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 1094 2006-12-19 12:11:44Z henrik $ """ 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() 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') 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) 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 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) if s_review_state == "application_pin_entered": rdirect_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() 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)