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

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

ticket #211

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1##parameters=REQUEST,matric_no=None
2# $Id: set_access_data.py 1794 2007-05-17 16:40:34Z 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())
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    st_res = context.returning_import(matric_no = matric_no)
24    if st_res:
25        sid = st_res[0].id
26        logger.info('Student object with matric_no %s does not exist in students_catalog. Id taken from returning_import.' % matric_no)
27    else:
28        logger.info('Student object with matric_no %s neither exists in students_catalog nor in returning_import.' % matric_no)
29        return
30res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search',
31                      schema_id= 'student_returning',
32                      context=context,
33                      mapping=validate and REQUEST,
34                      ob=default,
35                      layout_mode='edit',
36                      formaction = "set_access_data",
37                      button = "Search",
38                      matric_no = matric_no,
39                      commit = False,
40                      )
41if psm == '':
42    return context.set_access_data_form(rendered = res,
43                                 psm = None,
44                                 firstlayout = True,
45                                 lastlayout = True,
46                                 ds = ds,
47                                 name = "%(name)s" % REQUEST.form
48                                 )
49elif psm == 'invalid':
50    psm = "Please correct your input!"
51elif psm == 'valid' and not REQUEST.form.has_key('acknowledge'):
52    psm = "You did not check the ackkowledge box!"
53else:
54    password = REQUEST.get('widget__password')
55    try:
56        context.waeup_tool.makeStudentMember(sid,password=password)
57        psm = ''
58    except KeyError:
59        #psm = "You are already registered please log in with your UserId %s" % sid
60        psm = ""
61        logger.info('%s repeatedly tried to set password' % sid)
62    except:
63        psm = "The system encountered an error. Please try again."
64        logger.info('%s, makeStudentMember error, password = %s' % (sid,password))
65if psm != '':
66    return context.set_access_data_form(rendered = res,
67                                 #psm = "%s, %s" % (psm,ds),
68                                 psm = psm,
69                                 firstlayout = True,
70                                 lastlayout = True,
71                                 ds = ds,
72                                 name = "%(name)s" % REQUEST.form
73                                 )
74email = ds.get('email')
75args = {}
76args['__ac_name'] = sid
77args['__ac_password'] = password
78args['returning'] = '1'
79args['email'] = email
80args['phone_nr'] = ds.get('phone_nr')
81from urllib import urlencode
82url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args))
83return REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.