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

Last change on this file since 1273 was 1242, checked in by joachim, 18 years ago

fix

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