Ignore:
Timestamp:
16 Nov 2005, 16:44:13 (19 years ago)
Author:
joachim
Message:

=post-primary results adding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup_product/trunk/skins/waeup_student/eligibility.py

    r176 r179  
    1 ##parameters=REQUEST
     1##parameters=REQUEST=None
    22# $Id$
    33"""
     
    55return html renderer + psm
    66"""
    7 type_name = 'Jamb'
    8 ti = context.portal_types[type_name]
    9 
    10 REQUEST.set('type_name',type_name)
    11 
    12 validate = REQUEST.has_key("cpsdocument_edit_button")
     7request = REQUEST
     8rget = request.get
     9rset = request.set
     10fget = request.form.get
     11fhas = request.form.has_key
    1312
    1413
     
    1615pr = context.portal_registration
    1716pm = context.portal_membership
     17eli = context.ELIGIBILITY.getContent()
     18sr = eli.schoolresults
    1819
    19 jamb = getattr(context,'JAMB')
    20 jamb_rendered = jamb.getContent().render(layout_id = 'admission_slip',
    21                                layout_mode = 'view',
    22                                schema_id = 'jamb')
    23 
    24 res,psm,ds = lt.renderLayout(layout_id= 'student_eligibility',
     20res,psm,ds = lt.renderLayout(layout_id= 'student_schoolresults',
    2521                      schema_id= 'student_eligibility',
    2622                      context=context,
    27                       mapping=validate and REQUEST,
     23                      mapping=request,
    2824                      ob={},
    2925                      layout_mode='create',
     26                      formaction = "eligibility",
     27                      schoolresults = sr,
    3028                      )
    31 res = jamb_rendered + res
    32 if psm == 'invalid':
    33     return context.eligibility_form(rendered = res,
     29
     30inr = 0
     31if 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"
     34elif 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
     39elif 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
     48else:
     49    psm = ''
     50eli.edit(mapping={'schoolresults': sr})
     51res,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
     61return context.eligibility_form(rendered = res,
    3462                                 #psm = str(ds),
    35                                  psm = "Please correct your input",
    36                                  ds = ds,
     63                                 psm = psm,
    3764                                 )
    38 elif psm == '':
    39     return context.eligibility_form(rendered = res,
    40                                  psm = None,
    41                                  ds = ds,
    42                                  )
    43 elif psm == 'valid':
    44     s_personal = context.PERSONAL.getContent()
    45     s_personal.edit(mapping={'email': ds.get('email')})
    46     #pw = REQUEST.get("widget__pw")
    47     #pm.setPassword(pw)
    48 psm = 'Email has been successfully set.'
    49 return context.REQUEST.RESPONSE.redirect('%s' % context.portal_url.getUrlFromRpath('/students'))
    50 
    51 ##return context.eligibility_form(rendered = res,
    52 ##                                 psm = psm,
     65##elif psm == '':
     66##    return context.eligibility_form(rendered = res,
     67##                                 psm = None,
    5368##                                 ds = ds,
    5469##                                 )
     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####                                 )
Note: See TracChangeset for help on using the changeset viewer.