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

Last change on this file since 1206 was 1202, checked in by joachim, 18 years ago

catch dupplicat pw entry (in custom)

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1##parameters=REQUEST,matric_no
2# $Id: set_access_data.py 1202 2007-01-05 11:24:00Z joachim $
3"""
4process the Application Form
5return html renderer + psm
6"""
7import DateTime,logging
8current = DateTime.DateTime()
9pr = context.portal_registration
10logger = logging.getLogger('Returning')
11validate = REQUEST.has_key("cpsdocument_edit_button")
12
13lt = context.portal_layouts
14#pr = context.portal_registration
15default = {'matric_no':matric_no}
16st_res = context.students_catalog(matric_no = matric_no)
17if st_res:
18    sid = st_res[0].id
19else:
20    logger.info('"%s","Studentobject does not exist"' % matric_no)
21res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search',
22                      schema_id= 'student_returning',
23                      context=context,
24                      mapping=validate and REQUEST,
25                      ob=default,
26                      layout_mode='edit',
27                      formaction = "set_access_data",
28                      button = "Search",
29                      matric_no = matric_no,
30                      commit = False,
31                      )
32if psm == '':
33    return context.set_access_data_form(rendered = res,
34                                 psm = None,
35                                 firstlayout = True,
36                                 lastlayout = True,
37                                 ds = ds,
38                                 name = "%(name)s" % REQUEST.form
39                                 )
40elif psm == 'invalid':
41    psm = "Please correct your input!"
42elif psm == 'valid' and not REQUEST.form.has_key('acknowledge'):
43    psm = "You did not check the ackkowledge box!"
44else:
45    try:
46        password = REQUEST.get('widget__password')
47        context.waeup_tool.makeStudentMember(sid,password=password)
48        psm = ''
49    except KeyError:
50        psm = "You are already registered please log in with your UserId %s" % sid
51        logger.info('"%s","repeatedly tried to set password"' % sid)
52if psm != '':
53    return context.set_access_data_form(rendered = res,
54                                 #psm = "%s, %s" % (psm,ds),
55                                 psm = psm,
56                                 firstlayout = True,
57                                 lastlayout = True,
58                                 ds = ds,
59                                 name = "%(name)s" % REQUEST.form
60                                 )
61email = ds.get('email')
62args = {}
63args['__ac_name'] = sid
64args['__ac_password'] = password
65args['returning'] = '1'
66args['email'] = email
67args['phone_nr'] = ds.get('phone_nr')
68from urllib import urlencode
69url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args))
70return REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.