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

Last change on this file since 10272 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
RevLine 
[1207]1##parameters=REQUEST,matric_no=None
[1179]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
[1571]10logger = logging.getLogger('Skins.set_access_data')
[1179]11validate = REQUEST.has_key("cpsdocument_edit_button")
12
[1207]13if matric_no is None:
[1582]14    logger.info('No matric_no in request')
[1207]15    return REQUEST.RESPONSE.redirect("%s" % context.portal_url())
[1817]16matric_no = matric_no.upper()
[1179]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:
[1794]24    st_res = context.returning_import(matric_no = matric_no)
25    if st_res:
26        sid = st_res[0].id
[1826]27        logger.info('Student object with matric_no %s does not exist in students_catalog, Id taken from returning_import' % matric_no)
[1794]28    else:
[1826]29        logger.info('Student object with matric_no %s neither exists in students_catalog nor in returning_import' % matric_no)
[1794]30        return
[3367]31res,psm,ds = lt.renderLayout(layout_id= 'student_firsttime_login',
[1179]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:
[1207]55    password = REQUEST.get('widget__password')
[1202]56    try:
57        context.waeup_tool.makeStudentMember(sid,password=password)
58        psm = ''
59    except KeyError:
[1215]60        #psm = "You are already registered please log in with your UserId %s" % sid
61        psm = ""
[1571]62        logger.info('%s repeatedly tried to set password' % sid)
[1265]63    except:
[1267]64        psm = "The system encountered an error. Please try again."
[1571]65        logger.info('%s, makeStudentMember error, password = %s' % (sid,password))
[1179]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.