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

Last change on this file since 1188 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
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 1174 2007-01-02 11:03:16Z 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()
33
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        if request.has_key('email'):
40            context.waeup_tool.makeStudentData(str(member),
41                                               email=request.get("email"),
42                                               phone_nr=request.get("phone_nr"),
43                                               )
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)
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\
56                             a_review_state == 'created' :
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:
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
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\
78                                            not app_doc.app_ac_pin:
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":
94            rdirect_url = "%s/application_edit_form" % student.absolute_url()
95        elif s_review_state in ('admitted', 'objection_raised',):
96            redirect_url = "%s/admission_form" % student.absolute_url()
97        elif s_review_state == "clearance_pin_entered":
98            redirect_url = "%s/clearance_edit_form" % student.absolute_url()
99        if s_review_state == "returning":
100            redirect_url = "%s/session_results_view" % student.absolute_url()
101        else:
102            redirect_url = "%s/student_index" % student.absolute_url()
103    else:
104        logger.info('"%s", "logged in"' % (member))
105        redirect_url = portal.absolute_url()
106#Anonymous
107else:
108    response.expireCookie('__ac', path='/')
109    return context.user_logged_in_failed()
110
111# Setup skins
112if (getattr(utool, 'updateSkinCookie', False) and
113    utool.updateSkinCookie()):
114    context.setupCurrentSkin()
115
116response.redirect(redirect_url)
117
Note: See TracBrowser for help on using the repository browser.