source: WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py @ 1145

Last change on this file since 1145 was 1096, checked in by Henrik Bettermann, 18 years ago

redirect to illegal_view.py

  • Property svn:keywords set to Id
File size: 3.8 KB
RevLine 
[524]1## Script (Python) "logged_in"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
[1092]7##parameters=
[524]8##title=
9##
10"""Prepare user login
11modified from cps_default/logged_in.py
12
[805]13$Id: logged_in.py 1096 2006-12-19 21:56:55Z henrik $
[524]14"""
[535]15import DateTime
16current = DateTime.DateTime()
[1004]17import logging
[1082]18logger = logging.getLogger('Member.Login')
[524]19
[1004]20
[524]21from urllib import unquote
22
[535]23request = context.REQUEST
24response = request.RESPONSE
[524]25utool = context.portal_url
26mtool = context.portal_membership
[551]27wftool = context.portal_workflow
[524]28portal = utool.getPortalObject()
29
30redirect_to_portal = False
31is_anon = mtool.isAnonymousUser()
32member = mtool.getAuthenticatedMember()
33
[1092]34if not is_anon:
35    if "Student" in member.getRoles():
36        to_waeup_student_home = True
37        students = context.portal_url.getPortalObject().campus.students
38        student = getattr(students,str(member))
39        student_app = getattr(student,'application')
40        student_pume = getattr(student,'pume',None)
41        s_review_state = wftool.getInfoFor(student,'review_state',None)
42        a_review_state = wftool.getInfoFor(student_app,'review_state',None)
43        logger.info('"%s", "logged in", "review_state %s"' % (member,s_review_state))
44        app_doc = student_app.getContent()
45        #from Products.zdb import set_trace
46        #set_trace()
47        if s_review_state in ("student_created","admitted") and\
[1096]48                             a_review_state == 'created' :
[1092]49            wftool.doActionFor(student_app,'open')
50            if student_pume is not None:
51              wftool.doActionFor(student_pume,'close')
52            da = {}
53            pin = request.get('pin')
54            if not pin:
[999]55                jamb_reg_no = app_doc.jamb_reg_no
56                for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
57                    res = context.portal_pins(student=reg_no)
58                    if len(res) > 0:
59                        break
60                if len(res) > 0:
61                    p = res[0].pin
62                    if len(p) > 10:
63                        pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
64                    else:
65                        pin = p
[1092]66            da['app_ac_pin'] = pin
67            da['app_ac_date'] = current
68            app_doc.edit(mapping = da)
69        elif s_review_state in ("admitted") and a_review_state == 'opened' and\
[1096]70                                            not app_doc.app_ac_pin:
[1092]71            jamb_reg_no = app_doc.jamb_reg_no
72            for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
73                res = context.portal_pins(student=reg_no)
74                if len(res) > 0:
75                    break
76            if len(res) > 0:
77                p = res[0].pin
78                if len(p) > 10:
79                    pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
80                else:
81                    pin = p
82                da = {}
83                da['app_ac_pin'] = pin
84                app_doc.edit(mapping = da)
85        if s_review_state == "application_pin_entered":
[1094]86            rdirect_url = "%s/application_edit_form" % student.absolute_url()
[1092]87        elif s_review_state in ('admitted', 'objection_raised',):
[1094]88            redirect_url = "%s/admission_form" % student.absolute_url()
[1092]89        elif s_review_state == "clearance_pin_entered":
[1094]90            redirect_url = "%s/clearance_edit_form" % student.absolute_url()
[1096]91        else:
92            redirect_url = "%s/student_index" % student.absolute_url()
[1092]93    else:
94        logger.info('"%s", "logged in"' % (member))
[1094]95        redirect_url = portal.absolute_url()
96#Anonymous
[1092]97else:
98    response.expireCookie('__ac', path='/')
[524]99    return context.user_logged_in_failed()
100
[1094]101# Setup skins
102if (getattr(utool, 'updateSkinCookie', False) and
103    utool.updateSkinCookie()):
104    context.setupCurrentSkin()
[524]105
[1094]106response.redirect(redirect_url)
107
Note: See TracBrowser for help on using the repository browser.