Changeset 612 in tmcsimulator for branches/LCSv1/controllers/default.py


Ignore:
Timestamp:
04/02/2020 09:36:50 AM (6 years ago)
Author:
jdalbey
Message:

LCS Add special validation check to Search form (for lognum validation)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LCSv1/controllers/default.py

    r610 r612  
    4343                INPUT(_name='enddate',_class='date'),BR(), 
    4444                INPUT(_value="Search", _type='submit', _class="btn btn-primary btn-default", _style="margin:  7% 45% 2% 40%;")) 
    45     if form.process().accepted: 
     45    if form.process(onvalidation=special_validation).accepted: 
    4646        # Put the form fields into the session variables 
    4747        session.closureid = form.vars.closureid 
     
    5353        redirect(URL('results')) 
    5454    return dict(form=form) 
     55# Search Form: Special validation check to reject lognum without closureID 
     56def special_validation(form): 
     57    # Error if a lognum was given and no closure id 
     58    if (len(form.vars.lognum) > 0 and len(form.vars.closureid) == 0): 
     59       form.errors.lognum = 'Must provide a closureID when specifying a log number' 
    5560# Show the item that was found in the search 
    5661def results(): 
Note: See TracChangeset for help on using the changeset viewer.