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

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

layouts fixed
search_student again on students level (though causes much iowaits)

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