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

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

open personal object if in state cleared_and_validated

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
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
7##parameters=
8##title=
9##
10"""Prepare user login
11modified from cps_default/logged_in.py
12
13$Id: logged_in.py 1347 2007-01-25 10:34:33Z henrik $
14"""
15import DateTime
16current = DateTime.DateTime()
17import logging
18logger = logging.getLogger('Member.Login')
19
20
21from urllib import unquote
22
23request = context.REQUEST
24response = request.RESPONSE
25utool = context.portal_url
26mtool = context.portal_membership
27wftool = context.portal_workflow
28portal = utool.getPortalObject()
29
30redirect_to_portal = False
31is_anon = mtool.isAnonymousUser()
32member = mtool.getAuthenticatedMember()
33load_passport = hasattr(context.waeup_tool,'loadStudentFoto')
34
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))
40        student_app = getattr(student,'application',None)
41        if request.has_key('returning') and student_app is None:
42            email=request.get("email")
43            phone=request.get("phone_nr")
44            context.waeup_tool.makeStudentData(str(member),
45                                               email=email,
46                                               phone_nr=phone,
47                                               )
48            d = {}
49            d['id'] = str(member)
50            d['email'] = email
51            d['phone'] = phone
52            context.students_catalog.modifyRecord(**d)
53        elif student_app is None:
54            context.waeup_tool.makeStudentData(str(member))
55        student_app = getattr(student,'application',None)
56        if 'payments' not in student.objectIds():
57            student.invokeFactory('PaymentsFolder','payments')
58            payments = getattr(student,'payments')
59            wftool.doActionFor(payments,'open')
60            d = {}
61            d['Title'] = 'Online Payments'
62            payments.getContent().edit(mapping=d)
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)
66        student_per = getattr(student,'personal',None)
67        p_review_state = wftool.getInfoFor(student_per,'review_state',None)
68        logger.info('"%s", "logged in", "review_state %s"' % (member,s_review_state))
69        app_doc = student_app.getContent()
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))
74        if s_review_state in ("student_created","admitted") and\
75                             a_review_state == 'created' :
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:
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
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\
97                                            not app_doc.app_ac_pin:
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)
112        elif s_review_state in ("cleared_and_validated",) and\
113                             p_review_state == 'created' :
114            wftool.doActionFor(student_per,'open')
115       
116        if s_review_state == "application_pin_entered":
117            redirect_url = "%s/application_edit_form" % student.absolute_url()
118        elif s_review_state in ('admitted', 'objection_raised',):
119            redirect_url = "%s/admission_form" % student.absolute_url()
120        elif s_review_state == "clearance_pin_entered":
121            redirect_url = "%s/clearance_edit_form" % student.absolute_url()
122        elif s_review_state == "cleared_and_validated":
123            redirect_url = "%s/personal_edit_form" % student.absolute_url()
124        elif s_review_state == "returning":
125            redirect_url = "%s/session_results_view" % student.absolute_url()
126        else:
127            redirect_url = "%s/student_index" % student.absolute_url()
128    else:
129        logger.info('"%s", "logged in"' % (member))
130        redirect_url = portal.absolute_url()
131#Anonymous
132else:
133    response.expireCookie('__ac', path='/')
134    return context.user_logged_in_failed()
135
136# Setup skins
137if (getattr(utool, 'updateSkinCookie', False) and
138    utool.updateSkinCookie()):
139    context.setupCurrentSkin()
140
141response.redirect(redirect_url)
142
Note: See TracBrowser for help on using the repository browser.