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

Last change on this file since 182 was 182, checked in by joachim, 19 years ago

=eligibility edit geht fast

  • Property svn:keywords set to Id
File size: 3.1 KB
RevLine 
[179]1##parameters=REQUEST=None
[164]2# $Id: eligibility.py 182 2005-11-16 23:30:12Z joachim $
3"""
4process the Admission Form
5return html renderer + psm
6"""
[179]7request = REQUEST
8rget = request.get
9rset = request.set
10fget = request.form.get
[182]11form = request.form
[179]12fhas = request.form.has_key
[164]13
14
15lt = context.portal_layouts
16pr = context.portal_registration
17pm = context.portal_membership
[179]18eli = context.ELIGIBILITY.getContent()
19sr = eli.schoolresults
[164]20
[182]21validate = fhas('add') or fhas('change') or fhas('delete')
22
23form['widget__jamb_results'] = eli.jamb_results                     
24form['widget__jamb_aggregate'] =eli.jamb_aggregate
25form['widget__faculty'] =eli.faculty                     
26form['widget__course'] =eli.course       
27res,psm,ds = lt.renderLayout(layout_id= 'student_eligibility_edit',
[179]28                      schema_id= 'student_eligibility',
29                      context=context,
30                      mapping=request,
31                      ob={},
32                      layout_mode='create',
33                      formaction = "eligibility",
34                      schoolresults = sr,
35                      )
[164]36
[179]37inr = 0
[182]38rset('ds',ds)
[179]39if 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"
42elif 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
47elif 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
56else:
57    psm = ''
[182]58ds.set('schoolresults',sr)
59eli.edit(mapping={'schoolresults':sr,
60                  'jamb_aggregate': fget('widget__aggregate'),
61                  })
62#eli.edit(mapping=ds)
63res,dummy,ds = lt.renderLayout(layout_id= 'student_eligibility_edit',
[164]64                      schema_id= 'student_eligibility',
65                      context=context,
[179]66                      mapping=request,
[164]67                      ob={},
68                      layout_mode='create',
[179]69                      formaction = "eligibility",
70                      schoolresults = sr,
[164]71                      )
[179]72
73return context.eligibility_form(rendered = res,
[164]74                                 #psm = str(ds),
[179]75                                 psm = psm,
[164]76                                 )
[179]77##elif psm == '':
78##    return context.eligibility_form(rendered = res,
79##                                 psm = None,
[175]80##                                 ds = ds,
81##                                 )
[179]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####                                 )
Note: See TracBrowser for help on using the repository browser.