source: WAeUP_SRP/base/skins/waeup_student/check_admission.py @ 3576

Last change on this file since 3576 was 3367, checked in by Henrik Bettermann, 17 years ago

do not allow returning students to check admission

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1##parameters=REQUEST
2# $Id: check_admission.py 3367 2008-03-21 13:29:31Z henrik $
3"""
4request Clearance
5"""
6import DateTime
7from urllib import urlencode
8current = DateTime.DateTime()
9import logging
10logger = logging.getLogger('Skins.check_admission')
11pr = context.portal_registration
12type_name = 'StudentApplication'
13ti = context.portal_types[type_name]
14REQUEST.set('type_name',type_name)
15redirect = REQUEST.RESPONSE.redirect
16wf = context.portal_workflow
17validate = REQUEST.has_key("cpsdocument_create_button")
18
19mtool = context.portal_membership
20is_anon = mtool.isAnonymousUser()
21member = mtool.getAuthenticatedMember()
22
23lt = context.portal_layouts
24pr = context.portal_registration
25
26res,psm,ds = lt.renderLayout('student_application',
27                             'student_application',
28                             context,
29                             mapping=validate and REQUEST,
30                             layout_mode='create',
31                             ob={},
32                             commit=False,
33                             formaction = "check_admission",
34                             button = "Check",
35                             )
36if psm == 'invalid':
37    return context.check_admission_pin_form(rendered = res,
38                                 psm = "Please correct your input!",
39                                 #psm = "%s, %s" % (psm,ds),
40                                 firstlayout = True,
41                                 lastlayout = True,
42                                 ds = ds,
43                                 )
44elif psm == '':
45    return context.check_admission_pin_form(rendered = res,
46                                 psm = None,
47                                 firstlayout = True,
48                                 lastlayout = True,
49                                 ds = ds,
50                                 )
51elif psm == 'valid':
52    s_id = ds.get('s_id')
53    if is_anon and not s_id:
54        return context.check_admission_pin_form(rendered = res,
55                                 psm = "You are not allowed to call this form in this context. Please try to log in.",
56                                 #psm = "%s, %s" % (psm,ds),
57                                 firstlayout = True,
58                                 lastlayout = True,
59                                 ds = ds,
60                                 )
61    elif not is_anon:
62        return context.check_admission_pin_form(rendered = res,
63                                 psm = "You are already logged in!",
64                                 #psm = "%s, %s" % (psm,ds),
65                                 firstlayout = True,
66                                 lastlayout = True,
67                                 ds = ds,
68                                 )
69    #student = getattr(context.campus.students, s_id)
70    #review_state = wf.getInfoFor(student,'review_state',None)
71    #if review_state == "admission_rejected":
72    #    url = "%s/campus/students/%s/pume/admission_rejected_view" % (context.portal_url(),s_id)
73    #    return redirect(url)
74
75    pw = str(ds.get('app_ac_pin_n'))
76    logger.info('%s successfully checked admission and logged in with password %s' % (s_id,pw))
77    args = {}
78    args['__ac_name'] = s_id
79    #args['__ac_password'] = pin.split('-')[2]
80    args['__ac_password'] = pw
81    args['pin'] = str(ds.get('app_ac_pin_p')) + '-' + str(ds.get('app_ac_pin_b')) + '-' + str(ds.get('app_ac_pin_n'))
82##    args['email'] = email
83    url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args))
84    return redirect(url)
85
Note: See TracBrowser for help on using the repository browser.