source: WAeUP_SRP/trunk/skins/waeup_student/set_access_data.py @ 3728

Last change on this file since 3728 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.2 KB
Line 
1##parameters=REQUEST,matric_no=None
2# $Id: set_access_data.py 3367 2008-03-21 13:29:31Z henrik $
3"""
4process the Application Form
5return html renderer + psm
6"""
7import DateTime,logging
8current = DateTime.DateTime()
9pr = context.portal_registration
10logger = logging.getLogger('Skins.set_access_data')
11validate = REQUEST.has_key("cpsdocument_edit_button")
12
13if matric_no is None:
14    logger.info('No matric_no in request')
15    return REQUEST.RESPONSE.redirect("%s" % context.portal_url())
16matric_no = matric_no.upper()
17lt = context.portal_layouts
18#pr = context.portal_registration
19default = {'matric_no':matric_no}
20st_res = context.students_catalog(matric_no = matric_no)
21if st_res:
22    sid = st_res[0].id
23else:
24    st_res = context.returning_import(matric_no = matric_no)
25    if st_res:
26        sid = st_res[0].id
27        logger.info('Student object with matric_no %s does not exist in students_catalog, Id taken from returning_import' % matric_no)
28    else:
29        logger.info('Student object with matric_no %s neither exists in students_catalog nor in returning_import' % matric_no)
30        return
31res,psm,ds = lt.renderLayout(layout_id= 'student_firsttime_login',
32                      schema_id= 'student_returning',
33                      context=context,
34                      mapping=validate and REQUEST,
35                      ob=default,
36                      layout_mode='edit',
37                      formaction = "set_access_data",
38                      button = "Search",
39                      matric_no = matric_no,
40                      commit = False,
41                      )
42if psm == '':
43    return context.set_access_data_form(rendered = res,
44                                 psm = None,
45                                 firstlayout = True,
46                                 lastlayout = True,
47                                 ds = ds,
48                                 name = "%(name)s" % REQUEST.form
49                                 )
50elif psm == 'invalid':
51    psm = "Please correct your input!"
52elif psm == 'valid' and not REQUEST.form.has_key('acknowledge'):
53    psm = "You did not check the ackkowledge box!"
54else:
55    password = REQUEST.get('widget__password')
56    try:
57        context.waeup_tool.makeStudentMember(sid,password=password)
58        psm = ''
59    except KeyError:
60        #psm = "You are already registered please log in with your UserId %s" % sid
61        psm = ""
62        logger.info('%s repeatedly tried to set password' % sid)
63    except:
64        psm = "The system encountered an error. Please try again."
65        logger.info('%s, makeStudentMember error, password = %s' % (sid,password))
66if psm != '':
67    return context.set_access_data_form(rendered = res,
68                                 #psm = "%s, %s" % (psm,ds),
69                                 psm = psm,
70                                 firstlayout = True,
71                                 lastlayout = True,
72                                 ds = ds,
73                                 name = "%(name)s" % REQUEST.form
74                                 )
75email = ds.get('email')
76args = {}
77args['__ac_name'] = sid
78args['__ac_password'] = password
79args['returning'] = '1'
80args['email'] = email
81args['phone_nr'] = ds.get('phone_nr')
82from urllib import urlencode
83url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args))
84return REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.