source: waeup_product/trunk/skins/waeup_student/eligibility.py @ 251

Last change on this file since 251 was 191, checked in by Henrik Bettermann, 19 years ago
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1##parameters=REQUEST=None
2# $Id: eligibility.py 191 2005-11-17 14:24:09Z henrik $
3"""
4process the Admission Form
5return html renderer + psm
6"""
7request = REQUEST
8rget = request.get
9rset = request.set
10fget = request.form.get
11form = request.form
12fhas = request.form.has_key
13
14
15lt = context.portal_layouts
16pr = context.portal_registration
17pm = context.portal_membership
18eli = context.ELIGIBILITY.getContent()
19sr = eli.schoolresults
20
21validate = fhas('add') or fhas('change') or fhas('delete')
22data = {'faculty': eli.faculty,
23        'course': eli.course,
24        'jamb_aggregate': eli.jamb_aggregate,
25        }
26res,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                      )
35if psm == 'invalid':
36    return context.eligibility_form(rendered = res,
37                                 psm = 'Please correct your errors',
38                                 ds = ds,
39                                 )
40elif psm == '':
41    return context.eligibility_form(rendered = res,
42                                 psm = psm,
43                                 ds = ds,
44                                 )
45inr = 0
46if 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"
49elif 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
54elif 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
63elif psm == 'valid':
64    psm = "Your changes have been saved."
65
66ds.set('schoolresults',sr)
67eli.edit(mapping=ds)
68res,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
78return context.eligibility_form(rendered = res,
79                                 #psm = "%s <br /> %s" % (str(ds),str(lt.student_eligibility.getLayoutDefinition()))
80                                 psm = psm,
81                                 )
Note: See TracBrowser for help on using the repository browser.