1 | ##parameters=REQUEST,matric_no |
---|
2 | # $Id: set_access_data.py 1158 2006-12-30 16:58:14Z joachim $ |
---|
3 | """ |
---|
4 | process the Application Form |
---|
5 | return html renderer + psm |
---|
6 | """ |
---|
7 | import DateTime |
---|
8 | current = DateTime.DateTime() |
---|
9 | pr = context.portal_registration |
---|
10 | |
---|
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 | res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search', |
---|
17 | schema_id= 'student_returning', |
---|
18 | context=context, |
---|
19 | mapping=validate and REQUEST, |
---|
20 | ob=default, |
---|
21 | layout_mode='edit', |
---|
22 | formaction = "set_access_data", |
---|
23 | button = "Search", |
---|
24 | matric_no = matric_no, |
---|
25 | commit = False, |
---|
26 | ) |
---|
27 | if psm == 'invalid': |
---|
28 | return context.set_access_data_form(rendered = res, |
---|
29 | psm = "Please correct your input!", |
---|
30 | #psm = "%s, %s" % (psm,ds), |
---|
31 | firstlayout = True, |
---|
32 | lastlayout = True, |
---|
33 | ds = ds, |
---|
34 | ) |
---|
35 | elif psm == '': |
---|
36 | return context.set_access_data_form(rendered = res, |
---|
37 | psm = None, |
---|
38 | firstlayout = True, |
---|
39 | lastlayout = True, |
---|
40 | ds = ds, |
---|
41 | ) |
---|
42 | elif psm == 'valid': |
---|
43 | pass |
---|
44 | jamb_reg_no = ds.get('jamb_reg_no') |
---|
45 | r = context.returning_import(matric_no = matric_no) |
---|
46 | if r and r[0].Entryregno != jamb_reg_no or not r: |
---|
47 | psm = "Your Jamb Registration Nr is wrong" |
---|
48 | return context.set_access_data_form(rendered = res, |
---|
49 | psm = psm, |
---|
50 | firstlayout = True, |
---|
51 | lastlayout = True, |
---|
52 | ds = ds, |
---|
53 | ) |
---|
54 | ## from Products.zdb import set_trace;set_trace() |
---|
55 | password = REQUEST.get('widget__password') |
---|
56 | email = ds.get('email') |
---|
57 | st_res = context.students_catalog(matric_no = matric_no) |
---|
58 | if st_res: |
---|
59 | sid = st_res[0].id |
---|
60 | context.waeup_tool.makeStudentMember(sid,password=password) |
---|
61 | args = {} |
---|
62 | args['__ac_name'] = sid |
---|
63 | args['__ac_password'] = password |
---|
64 | args['returning'] = '1' |
---|
65 | args['email'] = email |
---|
66 | from urllib import urlencode |
---|
67 | url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) |
---|
68 | return REQUEST.RESPONSE.redirect(url) |
---|