Ignore:
Timestamp:
29 Aug 2007, 06:24:39 (17 years ago)
Author:
Henrik Bettermann
Message:

add new layout for application record management
(please test!)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_student/apply_pume_manage.py

    r2161 r2168  
    3737#REQUEST.set('type_name',type_name)
    3838reset = "reset" in request.keys()
     39edit = "edit" in request.keys()
    3940lt = context.portal_layouts
    4041
     
    4243new_reg_no = request.get('new_reg_no','').upper()
    4344
    44 if reset:
     45if reset or edit:
    4546    reg_no = reg_no
    4647elif new_reg_no:
     
    5051psm = ''
    5152object = {}
     53ds = []
     54
     55if reg_no:
     56    brains = context.applicants_catalog(reg_no = reg_no)
     57    if len(brains) == 1:
     58        for field in context.applicants_catalog.schema():
     59            object[field] = getattr(brains[0],field,None)
     60
     61        res,psm,ds = lt.renderLayout(layout_id= 'application_manage',
     62                                     schema_id= 'application',
     63                                     layout_mode = "edit",
     64                                     context=context,
     65                                     mapping=REQUEST,
     66                                     ob=object,
     67                                     commit = False,
     68                                    )
     69if psm == 'invalid':
     70    return context.apply_pume_manage_form(rendered = res,
     71                                   psm = "Please correct your input!",
     72                                   #psm = "%s, %s" % (psm,ds),
     73                                   ds = ds,
     74                                  )
     75elif psm == '':
     76    psm = 'Registration Number not found!'
     77    return context.apply_pume_manage_form(rendered = res,
     78                                   psm = psm,
     79                                   ds = ds,
     80                                  )
     81elif psm == 'valid':
     82    psm = ''
     83    pass
     84   
    5285data = {}
     86dm = ds.getDataModel()
     87for field in context.applicants_catalog.schema():
     88    if dm.has_key("%s" % field):
     89        data[field] = dm.get(field)
     90
     91
    5392if reset and reg_no:
    54     data['reg_no'] = reg_no
     93    #data['reg_no'] = reg_no
    5594    psm = "You successfully reset the record! The applicant will be able to edit and resubmit the data."
    5695    data['status'] = "reset"
     
    5897    logger.info('%s reset application record of %s' % (member,reg_no))
    5998
     99if edit and reg_no:
     100    #data['reg_no'] = reg_no
     101    psm = "Content changed!"
     102    context.applicants_catalog.modifyRecord(**data)
     103    logger.info('%s edited application record of %s' % (member,reg_no))
     104
    60105#set_trace()
    61106
    62 ds = []
     107
    63108if reg_no:
    64109    brains = context.applicants_catalog(reg_no = reg_no)
     
    66111        for field in context.applicants_catalog.schema():
    67112            object[field] = getattr(brains[0],field,None)
    68         res,psm_dummy,ds = lt.renderLayout(layout_id= 'application',
     113        res,psm_dummy,ds = lt.renderLayout(layout_id= 'application_manage',
    69114                                     schema_id= 'application',
    70                                      layout_mode = "view_slip",
     115                                     layout_mode = "edit",
    71116                                     context=context,
    72117                                     ob=object,
Note: See TracChangeset for help on using the changeset viewer.