1 | ##parameters=REQUEST=None |
---|
2 | # $Id: eligibility.py 179 2005-11-16 16:44:13Z 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 | fhas = request.form.has_key |
---|
12 | |
---|
13 | |
---|
14 | lt = context.portal_layouts |
---|
15 | pr = context.portal_registration |
---|
16 | pm = context.portal_membership |
---|
17 | eli = context.ELIGIBILITY.getContent() |
---|
18 | sr = eli.schoolresults |
---|
19 | |
---|
20 | res,psm,ds = lt.renderLayout(layout_id= 'student_schoolresults', |
---|
21 | schema_id= 'student_eligibility', |
---|
22 | context=context, |
---|
23 | mapping=request, |
---|
24 | ob={}, |
---|
25 | layout_mode='create', |
---|
26 | formaction = "eligibility", |
---|
27 | schoolresults = sr, |
---|
28 | ) |
---|
29 | |
---|
30 | inr = 0 |
---|
31 | if fhas('add') and (fget('type') or fget('subject') or fget('result')): |
---|
32 | sr.append((fget('type'),fget('subject'),fget('result'))) |
---|
33 | psm = "new result added" |
---|
34 | elif fhas('change') and fget('keys'): |
---|
35 | for k in fget('keys'): |
---|
36 | sr[int(k)] = (fget('type_%s' % k),fget('subject_%s' % k),fget('result_%s' % k)) |
---|
37 | inr += 1 |
---|
38 | psm = "%s items changed" % inr |
---|
39 | elif fhas('delete') and fget('keys'): |
---|
40 | new = [] |
---|
41 | todelete = fget('keys') |
---|
42 | for k in range(len(sr)): |
---|
43 | if str(k) not in todelete: |
---|
44 | new.append(sr[k]) |
---|
45 | inr = len(todelete) |
---|
46 | sr = new |
---|
47 | psm = "%s items deleted" % inr |
---|
48 | else: |
---|
49 | psm = '' |
---|
50 | eli.edit(mapping={'schoolresults': sr}) |
---|
51 | res,dummy,ds = lt.renderLayout(layout_id= 'student_schoolresults', |
---|
52 | schema_id= 'student_eligibility', |
---|
53 | context=context, |
---|
54 | mapping=request, |
---|
55 | ob={}, |
---|
56 | layout_mode='create', |
---|
57 | formaction = "eligibility", |
---|
58 | schoolresults = sr, |
---|
59 | ) |
---|
60 | |
---|
61 | return context.eligibility_form(rendered = res, |
---|
62 | #psm = str(ds), |
---|
63 | psm = psm, |
---|
64 | ) |
---|
65 | ##elif psm == '': |
---|
66 | ## return context.eligibility_form(rendered = res, |
---|
67 | ## psm = None, |
---|
68 | ## ds = ds, |
---|
69 | ## ) |
---|
70 | ##elif psm == 'valid': |
---|
71 | ## s_personal = context.PERSONAL.getContent() |
---|
72 | ## s_personal.edit(mapping={'email': ds.get('email')}) |
---|
73 | ## #pw = REQUEST.get("widget__pw") |
---|
74 | ## #pm.setPassword(pw) |
---|
75 | ##psm = 'Email has been successfully set.' |
---|
76 | ##return context.REQUEST.RESPONSE.redirect('%s' % context.portal_url.getUrlFromRpath('/students')) |
---|
77 | ## |
---|
78 | ####return context.eligibility_form(rendered = res, |
---|
79 | #### psm = psm, |
---|
80 | #### ds = ds, |
---|
81 | #### ) |
---|