- Timestamp:
- 12 May 2007, 16:18:27 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py
r1776 r1777 1 ## Script (Python) "logged_in"2 ##bind container=container3 ##bind context=context4 ##bind namespace=5 ##bind script=script6 ##bind subpath=traverse_subpath7 ##parameters=8 ##title=9 ##10 """Prepare user login11 modified from cps_default/logged_in.py12 13 $Id$14 """15 try:16 from Products.zdb import set_trace17 except:18 def set_trace():19 pass20 import DateTime21 current = DateTime.DateTime()22 import logging23 logger = logging.getLogger('Skins.logged_in')24 25 26 from urllib import unquote27 28 request = context.REQUEST29 response = request.RESPONSE30 utool = context.portal_url31 mtool = context.portal_membership32 wftool = context.portal_workflow33 portal = utool.getPortalObject()34 35 redirect_to_portal = False36 is_anon = mtool.isAnonymousUser()37 member = mtool.getAuthenticatedMember()38 load_passport = hasattr(context.waeup_tool,'loadStudentFoto')39 40 if not is_anon:41 if "Student" in member.getRoles():42 to_waeup_student_home = True43 students = context.portal_url.getPortalObject().campus.students44 student = getattr(students,str(member))45 student_app = getattr(student,'application',None)46 if request.has_key('returning') and student_app is None:47 email=request.get("email")48 phone=request.get("phone_nr")49 context.waeup_tool.makeStudentData(str(member),50 email=email,51 phone_nr=phone,52 )53 d = {}54 d['id'] = str(member)55 d['email'] = email56 d['phone'] = phone57 context.students_catalog.modifyRecord(**d)58 elif student_app is None:59 context.waeup_tool.makeStudentData(str(member))60 student_app = getattr(student,'application',None)61 if 'payments' not in student.objectIds():62 student.invokeFactory('PaymentsFolder','payments')63 payments = getattr(student,'payments')64 wftool.doActionFor(payments,'open')65 d = {}66 d['Title'] = 'Online Payments'67 payments.getContent().edit(mapping=d)68 student_pume = getattr(student,'pume',None)69 s_review_state = wftool.getInfoFor(student,'review_state',None)70 a_review_state = wftool.getInfoFor(student_app,'review_state',None)71 student_per = getattr(student,'personal',None)72 p_review_state = wftool.getInfoFor(student_per,'review_state',None)73 logger.info('%s logged in, review_state %s' % (member,s_review_state))74 app_doc = student_app.getContent()75 #from Products.zdb import set_trace;set_trace()76 if load_passport and 'passport' not in app_doc.objectIds():77 msg = context.waeup_tool.loadStudentFoto(student)78 logger.info('%s, %s' % (member,msg))79 if s_review_state in ("student_created","admitted") and\80 a_review_state == 'created' :81 wftool.doActionFor(student_app,'open')82 if student_pume is not None:83 wftool.doActionFor(student_pume,'close')84 da = {}85 pin = request.get('pin')86 if not pin:87 jamb_reg_no = app_doc.jamb_reg_no88 for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):89 res = context.portal_pins(student=reg_no)90 if len(res) > 0:91 break92 if len(res) > 0:93 p = res[0].pin94 if len(p) > 10:95 pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])96 else:97 pin = p98 da['app_ac_pin'] = pin99 da['app_ac_date'] = current100 app_doc.edit(mapping = da)101 elif s_review_state in ("admitted") and a_review_state == 'opened' and\102 not app_doc.app_ac_pin:103 jamb_reg_no = app_doc.jamb_reg_no104 for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):105 res = context.portal_pins(student=reg_no)106 if len(res) > 0:107 break108 if len(res) > 0:109 p = res[0].pin110 if len(p) > 10:111 pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])112 else:113 pin = p114 da = {}115 da['app_ac_pin'] = pin116 app_doc.edit(mapping = da)117 elif s_review_state in ("cleared_and_validated",) and\118 p_review_state == 'created' :119 wftool.doActionFor(student_per,'open')120 res = context.students_catalog(id = str(member))121 matric_no = res[0].matric_no122 verdict = res[0].verdict123 if s_review_state == "returning" and not verdict:124 results = context.results_import(matric_no = matric_no)125 if results:126 study_course_doc = getattr(student,'study_course').getContent()127 study_course_doc.edit(mapping={'verdict':results[0].Verdict})128 is_imported = context.returning_import(matric_no = matric_no)129 if s_review_state == "application_pin_entered":130 redirect_url = "%s/application_edit_form" % student.absolute_url()131 elif s_review_state in ('admitted', 'objection_raised',):132 redirect_url = "%s/admission_form" % student.absolute_url()133 elif s_review_state == "clearance_pin_entered":134 redirect_url = "%s/clearance_edit_form" % student.absolute_url()135 elif s_review_state == "cleared_and_validated":136 redirect_url = "%s/personal_edit_form" % student.absolute_url()137 elif s_review_state == "returning" and is_imported:138 redirect_url = "%s/session_results_view" % student.absolute_url()139 else:140 redirect_url = "%s/student_index" % student.absolute_url()141 else:142 logger.info('%s logged in' % (member))143 redirect_url = portal.absolute_url()144 #Anonymous145 else:146 response.expireCookie('__ac', path='/')147 return context.user_logged_in_failed()148 149 # Setup skins150 if (getattr(utool, 'updateSkinCookie', False) and151 utool.updateSkinCookie()):152 context.setupCurrentSkin()153 154 response.redirect(redirect_url)155
Note: See TracChangeset for help on using the changeset viewer.