1 | ##parameters=REQUEST=None |
---|
2 | # $Id: eligibility.py 182 2005-11-16 23:30:12Z joachim $ |
---|
3 | """ |
---|
4 | process the Admission Form |
---|
5 | return html renderer + psm |
---|
6 | """ |
---|
7 | request = REQUEST |
---|
8 | rget = request.get |
---|
9 | rset = request.set |
---|
10 | fget = request.form.get |
---|
11 | form = request.form |
---|
12 | fhas = request.form.has_key |
---|
13 | |
---|
14 | |
---|
15 | lt = context.portal_layouts |
---|
16 | pr = context.portal_registration |
---|
17 | pm = context.portal_membership |
---|
18 | eli = context.ELIGIBILITY.getContent() |
---|
19 | sr = eli.schoolresults |
---|
20 | |
---|
21 | validate = fhas('add') or fhas('change') or fhas('delete') |
---|
22 | |
---|
23 | form['widget__jamb_results'] = eli.jamb_results |
---|
24 | form['widget__jamb_aggregate'] =eli.jamb_aggregate |
---|
25 | form['widget__faculty'] =eli.faculty |
---|
26 | form['widget__course'] =eli.course |
---|
27 | res,psm,ds = lt.renderLayout(layout_id= 'student_eligibility_edit', |
---|
28 | schema_id= 'student_eligibility', |
---|
29 | context=context, |
---|
30 | mapping=request, |
---|
31 | ob={}, |
---|
32 | layout_mode='create', |
---|
33 | formaction = "eligibility", |
---|
34 | schoolresults = sr, |
---|
35 | ) |
---|
36 | |
---|
37 | inr = 0 |
---|
38 | rset('ds',ds) |
---|
39 | if fhas('add') and (fget('type') or fget('subject') or fget('result')): |
---|
40 | sr.append((fget('type'),fget('subject'),fget('result'))) |
---|
41 | psm = "new result added" |
---|
42 | elif fhas('change') and fget('keys'): |
---|
43 | for k in fget('keys'): |
---|
44 | sr[int(k)] = (fget('type_%s' % k),fget('subject_%s' % k),fget('result_%s' % k)) |
---|
45 | inr += 1 |
---|
46 | psm = "%s items changed" % inr |
---|
47 | elif fhas('delete') and fget('keys'): |
---|
48 | new = [] |
---|
49 | todelete = fget('keys') |
---|
50 | for k in range(len(sr)): |
---|
51 | if str(k) not in todelete: |
---|
52 | new.append(sr[k]) |
---|
53 | inr = len(todelete) |
---|
54 | sr = new |
---|
55 | psm = "%s items deleted" % inr |
---|
56 | else: |
---|
57 | psm = '' |
---|
58 | ds.set('schoolresults',sr) |
---|
59 | eli.edit(mapping={'schoolresults':sr, |
---|
60 | 'jamb_aggregate': fget('widget__aggregate'), |
---|
61 | }) |
---|
62 | #eli.edit(mapping=ds) |
---|
63 | res,dummy,ds = lt.renderLayout(layout_id= 'student_eligibility_edit', |
---|
64 | schema_id= 'student_eligibility', |
---|
65 | context=context, |
---|
66 | mapping=request, |
---|
67 | ob={}, |
---|
68 | layout_mode='create', |
---|
69 | formaction = "eligibility", |
---|
70 | schoolresults = sr, |
---|
71 | ) |
---|
72 | |
---|
73 | return context.eligibility_form(rendered = res, |
---|
74 | #psm = str(ds), |
---|
75 | psm = psm, |
---|
76 | ) |
---|
77 | ##elif psm == '': |
---|
78 | ## return context.eligibility_form(rendered = res, |
---|
79 | ## psm = None, |
---|
80 | ## ds = ds, |
---|
81 | ## ) |
---|
82 | ##elif psm == 'valid': |
---|
83 | ## s_personal = context.PERSONAL.getContent() |
---|
84 | ## s_personal.edit(mapping={'email': ds.get('email')}) |
---|
85 | ## #pw = REQUEST.get("widget__pw") |
---|
86 | ## #pm.setPassword(pw) |
---|
87 | ##psm = 'Email has been successfully set.' |
---|
88 | ##return context.REQUEST.RESPONSE.redirect('%s' % context.portal_url.getUrlFromRpath('/students')) |
---|
89 | ## |
---|
90 | ####return context.eligibility_form(rendered = res, |
---|
91 | #### psm = psm, |
---|
92 | #### ds = ds, |
---|
93 | #### ) |
---|