Changeset 2102 for WAeUP_SRP/trunk


Ignore:
Timestamp:
16 Aug 2007, 11:45:27 (17 years ago)
Author:
joachim
Message:

better version

File:
1 edited

Legend:

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

    r2098 r2102  
    2929apply_pume = "apply" in request.keys()
    3030edit = "edit" in request.keys()
     31submitted = False
    3132mode = request.get('mode','')
    3233if not mode:
     
    4041reg_no = request.get('widget__reg_no','').upper()
    4142if not reg_no:
    42     reg_no = request.get('reg_no','').upper()
    43    
     43    reg_no = request.form.get('reg_no','').upper()
     44pin = request.form.get('pin','')
    4445object = {}
    45 #set_trace()
    4646if reg_no:
    4747    brains = context.applicants_catalog(reg_no = reg_no)
     
    4949        for field in context.applicants_catalog.schema():
    5050            object[field] = getattr(brains[0],field,None)
     51        if object['status'] == "submitted":
     52            submitted = True
     53        #set_trace()
     54        if not create and pin != object['pin']:
     55            return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
    5156
    5257res,psm,ds = lt.renderLayout(layout_id= 'application',
     
    5964                            )
    6065
     66set_trace()
    6167if psm == 'invalid':
    6268    return context.apply_pume_form(rendered = res,
     
    7480elif psm == 'valid':
    7581    pass
    76 if create or edit or apply_pume:
    77     data = {}
    78     for field in context.applicants_catalog.schema():
    79         if ds.has_key(field) and request.has_key("widget__%s" % field):
    80             data[field] = ds.get(field)
    81     data['reg_no'] = reg_no
    82     if apply_pume:
    83         data['registration_date'] = current
    84         data['status'] = "submitted"
    85     context.applicants_catalog.modifyRecord(**data)
    86     if apply_pume:
    87         if not request.has_key('confirm'):
    88             return context.apply_pume_form(rendered = res,
    89                                         psm = "Please confirm Passport Photograph",
    90                                         #psm = "%s, %s" % (psm,ds),
    91                                         mode = mode,
    92                                         ds = ds,
    93                                         )
    94                    
    95         return request.RESPONSE.redirect("%s/apply_pume?mode=view&reg_no=%s" %
    96                                      (context.absolute_url(),ds.get('reg_no')))
    97     elif edit or create:
    98         return request.RESPONSE.redirect("%s/apply_pume?mode=edit&reg_no=%s" %
    99                                      (context.absolute_url(),ds.get('reg_no')))
     82data = {}
     83for field in context.applicants_catalog.schema():
     84    if ds.has_key(field) and request.has_key("widget__%s" % field):
     85        data[field] = ds.get(field)
     86data['reg_no'] = reg_no
     87if apply_pume:
     88    data['registration_date'] = current
     89    data['status'] = "submitted"
     90context.applicants_catalog.modifyRecord(**data)
     91if apply_pume:
     92    if not request.has_key('confirm'):
     93        mode = "edit"
     94        psm = "Please confirm Passport Photograph"
     95    else:
     96        mode = "view"
     97        psm = "You successfully applied for PUME"
     98elif create:
     99    if submitted:
     100        mode = "view"
     101    else:
     102        mode = "edit"
     103    psm = ""
     104    #set_trace()
     105    object['pin'] = str(ds.get('pin'))
     106    res,psm,dummy = lt.renderLayout(layout_id= 'application',
     107                                schema_id= 'application',
     108                                layout_mode = mode,
     109                                context=context,
     110                                mapping={},
     111                                ob=object,
     112                                commit = False,
     113                                )
     114elif edit:
     115    mode = "edit"
     116    psm = "Content changed"
     117
     118return context.apply_pume_form(rendered = res,
     119                            psm = psm,
     120                            #psm = "%s, %s" % (psm,ds),
     121                            mode = mode,
     122                            ds = ds,
     123                            )
    100124
    101125
Note: See TracChangeset for help on using the changeset viewer.