Index: WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py_old
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py_old	(revision 1431)
+++ 	(revision )
@@ -1,158 +1,0 @@
-## Script (Python) "logged_in"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=came_from=None
-##title=
-##
-"""Prepare user login
-modified from cps_default/logged_in.py
-
-$Id: logged_in.py 1082 2006-12-18 21:25:01Z henrik $
-"""
-import DateTime
-current = DateTime.DateTime()
-import logging
-logger = logging.getLogger('Member.Login')
-
-
-from urllib import unquote
-
-def checkRedirect(portal, mtool):
-    to_member_home = False
-    to_workspaces = False
-##    has_home = mtool.getHomeFolder()
-##    if has_home:
-##        to_member_home = True
-##    if not has_home and mtool.checkPermission('View', portal.workspaces):
-##        to_workspaces = True
-    return to_member_home, to_workspaces
-
-request = context.REQUEST
-response = request.RESPONSE
-utool = context.portal_url
-mtool = context.portal_membership
-wftool = context.portal_workflow
-portal = utool.getPortalObject()
-portal_absolute_url = portal.absolute_url()
-
-redirect_url = came_from
-redirect_to_portal = False
-to_member_home = False
-to_workspaces = False
-to_waeup_student_home = False
-
-is_anon = mtool.isAnonymousUser()
-member = mtool.getAuthenticatedMember()
-
-if redirect_url and redirect_url.endswith('/logged_out'):
-    redirect_to_portal = True
-else:
-    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)
-        elif "Manager" in member.getRoles():
-            pass
-        else:
-            to_member_home, to_workspaces = checkRedirect(portal, mtool)
-
-if (not to_member_home) and (not to_workspaces):
-    redirect_to_portal = True
-
-if to_waeup_student_home:
-    #member.setProperties(last_login_time=current,login_time=current)
-    #if info['review_state'] == "application_pin_entered":
-    if s_review_state == "application_pin_entered":
-        return response.redirect("%s/application_edit_form" % student.absolute_url())
-    #elif info['review_state'] == "admitted":
-    elif s_review_state in ('admitted', 'objection_raised',):
-        return response.redirect("%s/admission_form" % student.absolute_url())
-    #elif info['review_state'] == "clearance_pin_entered":
-    elif s_review_state == "clearance_pin_entered":
-        return response.redirect("%s/clearance_edit_form" % student.absolute_url())
-    return response.redirect("%s/student_index" % student.absolute_url())
-
-elif to_member_home:
-    redirect_url = mtool.getHomeFolder().absolute_url()
-    logger.info('"%s", "logged in to_member_home"' % (member))
-elif to_workspaces:
-    redirect_url = portal.workspaces.absolute_url()
-    logger.info('"%s", "logged in to_workspace"' % (member))
-elif redirect_to_portal:
-    redirect_url = portal_absolute_url
-    logger.info('"%s", "logged in to_portal"' % (member))
-
-REQUEST = context.REQUEST
-RESPONSE = REQUEST.RESPONSE
-
-# Setup skins
-if (getattr(utool, 'updateSkinCookie', False) and
-    utool.updateSkinCookie()):
-    context.setupCurrentSkin()
-
-# Anonymous
-if is_anon:
-    RESPONSE.expireCookie('__ac', path='/')
-    return context.user_logged_in_failed()
-
-login_time = member.getProperty('login_time', '2000/01/01')
-first_time = (str(login_time) == '2000/01/01')
-
-##if first_time and member.has_role('Member') and not member.has_role('Student'):
-##    mtool.createMemberArea()
-##    now = context.ZopeTime()
-##    member.setProperties(last_login_time=now, login_time=now)
-
-if to_member_home or to_workspaces:
-    redirect_url = '%s/?%s' % (redirect_url, 'portal_status_message=psm_logged_in')
-RESPONSE.redirect(redirect_url)
