1 | ##parameters=REQUEST=None |
---|
2 | # $Id: eligibility.py 191 2005-11-17 14:24:09Z henrik $ |
---|
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 | data = {'faculty': eli.faculty, |
---|
23 | 'course': eli.course, |
---|
24 | 'jamb_aggregate': eli.jamb_aggregate, |
---|
25 | } |
---|
26 | res,psm,ds = lt.renderLayout(layout_id= 'student_eligibility', |
---|
27 | schema_id= 'student_eligibility', |
---|
28 | context=context, |
---|
29 | mapping=validate and request, |
---|
30 | ob=data, |
---|
31 | layout_mode='create', |
---|
32 | formaction = "eligibility", |
---|
33 | schoolresults = sr, |
---|
34 | ) |
---|
35 | if psm == 'invalid': |
---|
36 | return context.eligibility_form(rendered = res, |
---|
37 | psm = 'Please correct your errors', |
---|
38 | ds = ds, |
---|
39 | ) |
---|
40 | elif psm == '': |
---|
41 | return context.eligibility_form(rendered = res, |
---|
42 | psm = psm, |
---|
43 | ds = ds, |
---|
44 | ) |
---|
45 | inr = 0 |
---|
46 | if fhas('add') and (fget('type') or fget('subject') or fget('result')): |
---|
47 | sr.append((fget('type'),fget('subject'),fget('result'))) |
---|
48 | psm = "new result added" |
---|
49 | elif fhas('change') and fget('keys'): |
---|
50 | for k in fget('keys'): |
---|
51 | sr[int(k)] = (fget('type_%s' % k),fget('subject_%s' % k),fget('result_%s' % k)) |
---|
52 | inr += 1 |
---|
53 | psm = "%s items changed" % inr |
---|
54 | elif fhas('delete') and fget('keys'): |
---|
55 | new = [] |
---|
56 | todelete = fget('keys') |
---|
57 | for k in range(len(sr)): |
---|
58 | if str(k) not in todelete: |
---|
59 | new.append(sr[k]) |
---|
60 | inr = len(todelete) |
---|
61 | sr = new |
---|
62 | psm = "%s items deleted" % inr |
---|
63 | elif psm == 'valid': |
---|
64 | psm = "Your changes have been saved." |
---|
65 | |
---|
66 | ds.set('schoolresults',sr) |
---|
67 | eli.edit(mapping=ds) |
---|
68 | res,dummy,fds = lt.renderLayout(layout_id= 'student_eligibility', |
---|
69 | schema_id= 'student_eligibility', |
---|
70 | context=context, |
---|
71 | mapping=request, |
---|
72 | ob={}, |
---|
73 | layout_mode='create', |
---|
74 | formaction = "eligibility", |
---|
75 | schoolresults = sr, |
---|
76 | ) |
---|
77 | |
---|
78 | return context.eligibility_form(rendered = res, |
---|
79 | #psm = "%s <br /> %s" % (str(ds),str(lt.student_eligibility.getLayoutDefinition())) |
---|
80 | psm = psm, |
---|
81 | ) |
---|