1 | ##parameters=REQUEST,matric_no |
---|
2 | # $Id: set_access_data.py 1179 2007-01-02 21:29:17Z henrik $ |
---|
3 | """ |
---|
4 | process the Application Form |
---|
5 | return html renderer + psm |
---|
6 | """ |
---|
7 | import DateTime,logging |
---|
8 | current = DateTime.DateTime() |
---|
9 | pr = context.portal_registration |
---|
10 | logger = logging.getLogger('Returning') |
---|
11 | validate = REQUEST.has_key("cpsdocument_edit_button") |
---|
12 | |
---|
13 | lt = context.portal_layouts |
---|
14 | #pr = context.portal_registration |
---|
15 | default = {'matric_no':matric_no} |
---|
16 | st_res = context.students_catalog(matric_no = matric_no) |
---|
17 | if st_res: |
---|
18 | sid = st_res[0].id |
---|
19 | else: |
---|
20 | logger.info('"%s","Studentobject does not exist"' % matric_no) |
---|
21 | res,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 | ) |
---|
32 | if 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 | ) |
---|
40 | elif psm == 'invalid': |
---|
41 | psm = "Please correct your input!" |
---|
42 | elif psm == 'valid' and not REQUEST.form.has_key('acknowledge'): |
---|
43 | psm = "You did not check the ackkowledge box!" |
---|
44 | else: |
---|
45 | psm = '' |
---|
46 | if psm != '': |
---|
47 | return context.set_access_data_form(rendered = res, |
---|
48 | #psm = "%s, %s" % (psm,ds), |
---|
49 | psm = psm, |
---|
50 | firstlayout = True, |
---|
51 | lastlayout = True, |
---|
52 | ds = ds, |
---|
53 | name = "%(name)s" % REQUEST.form |
---|
54 | ) |
---|
55 | password = REQUEST.get('widget__password') |
---|
56 | email = ds.get('email') |
---|
57 | context.waeup_tool.makeStudentMember(sid,password=password) |
---|
58 | args = {} |
---|
59 | args['__ac_name'] = sid |
---|
60 | args['__ac_password'] = password |
---|
61 | args['returning'] = '1' |
---|
62 | args['email'] = email |
---|
63 | args['phone_nr'] = ds.get('phone_nr') |
---|
64 | from urllib import urlencode |
---|
65 | url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) |
---|
66 | return REQUEST.RESPONSE.redirect(url) |
---|