Changeset 1098 for WAeUP_SRP/trunk


Ignore:
Timestamp:
20 Dec 2006, 01:40:01 (18 years ago)
Author:
joachim
Message:

check for missing files

File:
1 edited

Legend:

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

    r1082 r1098  
    1717import logging
    1818logger = logging.getLogger('Student.Clearance.Edit')
     19request = REQUEST
    1920
    2021cpsdocument_edit_button = REQUEST.has_key('cpsdocument_edit_button')
     
    2223clear_and_validate_button = REQUEST.has_key('clear_and_validate_button')
    2324reject_clearance_button = REQUEST.has_key('reject_clearance_button')
     25result_edit_button = REQUEST.has_key('result_edit_button')
    2426
    2527# Until ajax posts directly to its own script...
     
    3234info = context.getClearanceInfo()
    3335
    34 
    3536#'Sorry, you are not allowed to access this page!'
    3637if info == None:
    37   #return REQUEST.RESPONSE.redirect(context.portal_url())
    3838  return REQUEST.RESPONSE.redirect(context.standard_error_message())
    39 
    40 
    4139student = info['student']
    42 app = info['app']
    43 app_doc = info['app_doc']
     40#app = info['app']
     41#app_doc = info['app_doc']
    4442clear = info['clear']
    4543clear_doc = info['clear_doc']
    4644student_id = info['id']
    4745member_id = str(context.portal_membership.getAuthenticatedMember())
     46result_widgets = ('fst_sit_results',
     47                  'scd_sit_results',
     48                  'alr_results',
     49                  )
     50required_scans = ('fst_sit_scan',
     51                  'jamb_slip',
     52                  'ref_letter',
     53                  'acc_let'
     54                  )
     55form = request.form
     56psm = ""
     57args = {}
     58action = "/external_clearance_edit_form"
     59if context.isStudent():
     60    action = "/clearance_edit_form"
    4861
     62##if result_edit_button:
     63##    dict = {}
     64##    for w in result_widgets:
     65##        if form.has_key("%s_s" % w):
     66##            v = getattr(clear_doc,w)
     67##            s = form.get("%s_s" % w)
     68##            g = form.get("%s_g" % w)
     69##            while 1:
     70##                if not s and g:
     71##                    break
     72##                i = 0
     73##                done = False
     74##                for sv,gv in v:
     75##                    if sv == s:
     76##                        done = True
     77##                        if not g:
     78##                            v.pop(i)
     79##                            break
     80##                        v[i] = (s,g)
     81##                        break
     82##                    i += 1
     83##                if done:
     84##                    break
     85##                if s and g:
     86##                    v.append((s,g))
     87##                break
     88##            dict[w] = v
     89##            #request.SESSION.set(w,v)
     90##    clear_doc.edit(mapping=dict)
     91##    args['portal_status_message'] = "Results updated"
     92##    url = clear.absolute_url() + action + '?' + urlencode(args)
     93##    REQUEST.RESPONSE.redirect(url)
    4994is_valid, ds = clear_doc.validate(request=REQUEST,
    5095                                schema_id = 'student_clearance',
     
    5398                                use_session=True)
    5499
    55 psm = ""
    56 args = {}
    57 action = "/external_clearance_edit_form"
    58 if context.isStudent():
    59     action = "/clearance_edit_form"
    60100
    61101if is_valid:
    62     if cpsdocument_edit_button:
     102    if cpsdocument_edit_button or result_edit_button:
    63103        psm = "Content changed!"
    64104        logger.info('"%s","edited clearance of","%s"' % (member_id,student_id ))
     
    74114    elif cpsdocument_edit_and_view_button:
    75115        if acknowledge and info['review_state'] == "clearance_pin_entered":
    76             logger.info('"%s","requested clearance"' % (student_id))
    77             info['clear_doc'].edit(mapping = {'request_date': current,})
    78             wftool.doActionFor(info['clear'],'close')
    79             wftool.doActionFor(info['student'],'request_clearance',dest_container=1)
    80             psm = "You successfully requested clearance!"
    81             if context.isStudent():
    82                action = "/clearance_view"
     116            missing = False
     117            for scan in required_scans:
     118                if not hasattr(clear_doc,scan):
     119                    missing = True
     120                    break
     121            if not missing:
     122                if not hasattr(clear_doc,"age_dec") and\
     123                not hasattr(clear_doc,"birth_certificate"):
     124                    missing = True
     125            if missing:
     126                logger.info('"%s","requested clearance with documents missing"' % (student_id))
     127                psm = "You have not uploaded all necessary documents to request clearance"
     128            else:
     129                logger.info('"%s","requested clearance"' % (student_id))
     130                info['clear_doc'].edit(mapping = {'request_date': current,})
     131                wftool.doActionFor(info['clear'],'close')
     132                wftool.doActionFor(info['student'],'request_clearance',dest_container=1)
     133                psm = "You successfully requested clearance!"
     134                if context.isStudent():
     135                    action = "/clearance_view"
    83136        elif acknowledge and info['review_state'] != "clearance_pin_entered":
    84137            logger.info('"%s","repeatedly requested clearance"' % (student_id))
Note: See TracChangeset for help on using the changeset viewer.