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

Last change on this file since 1426 was 1417, checked in by joachim, 18 years ago

Edit student_study course added
verdicts vocabulary added
new levels are only created, when no level there,
allow loggin for returning students, which have been created with add_student

  • Property svn:keywords set to Id
File size: 5.7 KB
RevLine 
[1346]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 1417 2007-02-15 10:56:43Z 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()
[1285]33load_passport = hasattr(context.waeup_tool,'loadStudentFoto')
[524]34
[1092]35if not is_anon:
36    if "Student" in member.getRoles():
37        to_waeup_student_home = True
38        students = context.portal_url.getPortalObject().campus.students
39        student = getattr(students,str(member))
[1228]40        student_app = getattr(student,'application',None)
41        if request.has_key('returning') and student_app is None:
[1215]42            email=request.get("email")
43            phone=request.get("phone_nr")
[1158]44            context.waeup_tool.makeStudentData(str(member),
[1215]45                                               email=email,
46                                               phone_nr=phone,
[1158]47                                               )
[1215]48            d = {}
49            d['id'] = str(member)
50            d['email'] = email
51            d['phone'] = phone
52            context.students_catalog.modifyRecord(**d)
[1231]53        elif student_app is None:
[1151]54            context.waeup_tool.makeStudentData(str(member))
55        student_app = getattr(student,'application',None)
[1241]56        if 'payments' not in student.objectIds():
57            student.invokeFactory('PaymentsFolder','payments')
58            payments = getattr(student,'payments')
[1242]59            wftool.doActionFor(payments,'open')
[1241]60            d = {}
61            d['Title'] = 'Online Payments'
62            payments.getContent().edit(mapping=d)
[1092]63        student_pume = getattr(student,'pume',None)
64        s_review_state = wftool.getInfoFor(student,'review_state',None)
65        a_review_state = wftool.getInfoFor(student_app,'review_state',None)
[1347]66        student_per = getattr(student,'personal',None)
67        p_review_state = wftool.getInfoFor(student_per,'review_state',None)
[1092]68        logger.info('"%s", "logged in", "review_state %s"' % (member,s_review_state))
69        app_doc = student_app.getContent()
[1285]70        #from Products.zdb import set_trace;set_trace()
71        if load_passport and 'passport' not in app_doc.objectIds():
72            msg = context.waeup_tool.loadStudentFoto(student)
73            logger.info('"%s", "%s"' % (member,msg))
[1092]74        if s_review_state in ("student_created","admitted") and\
[1096]75                             a_review_state == 'created' :
[1092]76            wftool.doActionFor(student_app,'open')
77            if student_pume is not None:
78              wftool.doActionFor(student_pume,'close')
79            da = {}
80            pin = request.get('pin')
81            if not pin:
[999]82                jamb_reg_no = app_doc.jamb_reg_no
83                for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
84                    res = context.portal_pins(student=reg_no)
85                    if len(res) > 0:
86                        break
87                if len(res) > 0:
88                    p = res[0].pin
89                    if len(p) > 10:
90                        pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
91                    else:
92                        pin = p
[1092]93            da['app_ac_pin'] = pin
94            da['app_ac_date'] = current
95            app_doc.edit(mapping = da)
96        elif s_review_state in ("admitted") and a_review_state == 'opened' and\
[1096]97                                            not app_doc.app_ac_pin:
[1092]98            jamb_reg_no = app_doc.jamb_reg_no
99            for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
100                res = context.portal_pins(student=reg_no)
101                if len(res) > 0:
102                    break
103            if len(res) > 0:
104                p = res[0].pin
105                if len(p) > 10:
106                    pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
107                else:
108                    pin = p
109                da = {}
110                da['app_ac_pin'] = pin
111                app_doc.edit(mapping = da)
[1347]112        elif s_review_state in ("cleared_and_validated",) and\
113                             p_review_state == 'created' :
114            wftool.doActionFor(student_per,'open')
[1417]115        res = context.students_catalog(id = str(member))
116        matric_no = res[0].matric_no
117        is_imported = context.returning_import(matric_no = matric_no)
[1092]118        if s_review_state == "application_pin_entered":
[1344]119            redirect_url = "%s/application_edit_form" % student.absolute_url()
[1092]120        elif s_review_state in ('admitted', 'objection_raised',):
[1094]121            redirect_url = "%s/admission_form" % student.absolute_url()
[1092]122        elif s_review_state == "clearance_pin_entered":
[1094]123            redirect_url = "%s/clearance_edit_form" % student.absolute_url()
[1347]124        elif s_review_state == "cleared_and_validated":
125            redirect_url = "%s/personal_edit_form" % student.absolute_url()
[1417]126        elif s_review_state == "returning" and is_imported:
[1174]127            redirect_url = "%s/session_results_view" % student.absolute_url()
[1096]128        else:
129            redirect_url = "%s/student_index" % student.absolute_url()
[1092]130    else:
131        logger.info('"%s", "logged in"' % (member))
[1094]132        redirect_url = portal.absolute_url()
133#Anonymous
[1092]134else:
135    response.expireCookie('__ac', path='/')
[524]136    return context.user_logged_in_failed()
137
[1094]138# Setup skins
139if (getattr(utool, 'updateSkinCookie', False) and
140    utool.updateSkinCookie()):
141    context.setupCurrentSkin()
[524]142
[1094]143response.redirect(redirect_url)
144
Note: See TracBrowser for help on using the repository browser.