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

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

sessional result view and slip added
names imported into application object

  • Property svn:keywords set to Id
File size: 4.3 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 1174 2007-01-02 11:03:16Z 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))
[1151]39        if request.has_key('email'):
[1158]40            context.waeup_tool.makeStudentData(str(member),
41                                               email=request.get("email"),
42                                               phone_nr=request.get("phone_nr"),
43                                               )
[1151]44        student_app = getattr(student,'application',None)
45        if student_app is None:
46            context.waeup_tool.makeStudentData(str(member))
47        student_app = getattr(student,'application',None)
[1092]48        student_pume = getattr(student,'pume',None)
49        s_review_state = wftool.getInfoFor(student,'review_state',None)
50        a_review_state = wftool.getInfoFor(student_app,'review_state',None)
51        logger.info('"%s", "logged in", "review_state %s"' % (member,s_review_state))
52        app_doc = student_app.getContent()
53        #from Products.zdb import set_trace
54        #set_trace()
55        if s_review_state in ("student_created","admitted") and\
[1096]56                             a_review_state == 'created' :
[1092]57            wftool.doActionFor(student_app,'open')
58            if student_pume is not None:
59              wftool.doActionFor(student_pume,'close')
60            da = {}
61            pin = request.get('pin')
62            if not pin:
[999]63                jamb_reg_no = app_doc.jamb_reg_no
64                for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
65                    res = context.portal_pins(student=reg_no)
66                    if len(res) > 0:
67                        break
68                if len(res) > 0:
69                    p = res[0].pin
70                    if len(p) > 10:
71                        pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
72                    else:
73                        pin = p
[1092]74            da['app_ac_pin'] = pin
75            da['app_ac_date'] = current
76            app_doc.edit(mapping = da)
77        elif s_review_state in ("admitted") and a_review_state == 'opened' and\
[1096]78                                            not app_doc.app_ac_pin:
[1092]79            jamb_reg_no = app_doc.jamb_reg_no
80            for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
81                res = context.portal_pins(student=reg_no)
82                if len(res) > 0:
83                    break
84            if len(res) > 0:
85                p = res[0].pin
86                if len(p) > 10:
87                    pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
88                else:
89                    pin = p
90                da = {}
91                da['app_ac_pin'] = pin
92                app_doc.edit(mapping = da)
93        if s_review_state == "application_pin_entered":
[1094]94            rdirect_url = "%s/application_edit_form" % student.absolute_url()
[1092]95        elif s_review_state in ('admitted', 'objection_raised',):
[1094]96            redirect_url = "%s/admission_form" % student.absolute_url()
[1092]97        elif s_review_state == "clearance_pin_entered":
[1094]98            redirect_url = "%s/clearance_edit_form" % student.absolute_url()
[1171]99        if s_review_state == "returning":
[1174]100            redirect_url = "%s/session_results_view" % student.absolute_url()
[1096]101        else:
102            redirect_url = "%s/student_index" % student.absolute_url()
[1092]103    else:
104        logger.info('"%s", "logged in"' % (member))
[1094]105        redirect_url = portal.absolute_url()
106#Anonymous
[1092]107else:
108    response.expireCookie('__ac', path='/')
[524]109    return context.user_logged_in_failed()
110
[1094]111# Setup skins
112if (getattr(utool, 'updateSkinCookie', False) and
113    utool.updateSkinCookie()):
114    context.setupCurrentSkin()
[524]115
[1094]116response.redirect(redirect_url)
117
Note: See TracBrowser for help on using the repository browser.