Changeset 626 in tmcsimulator for branches/LCSv2/controllers/default.py


Ignore:
Timestamp:
08/30/2020 01:49:28 PM (6 years ago)
Author:
jdalbey
Message:

LCS Add revision number to Help page. Add resetdb page.

File:
1 edited

Legend:

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

    r624 r626  
    299299    return dict(form=form) 
    300300 
     301# An unlinked page to allow admin to reset the database to simulation start state 
     302def resetdb(): 
     303    form = FORM("Press this button to reset the closure database to its original state at the start of a simulation.",BR(), 
     304                "Warning: this will delete all the current closures.",BR(), 
     305                "Import filename is 'db_closures_start.csv'.",BR(), 
     306                INPUT(_value="Reset Database", _type='submit', _class="btn btn-primary btn-default")) 
     307    if form.process().accepted: 
     308        db(db.closures.id > 0).delete()   # remove all current records 
     309        with open('db_closures_start.csv', 'rb') as dumpfile: 
     310            db.closures.import_from_csv_file(dumpfile)  # import from starting state 
     311        session.flash = 'Closure database has been reset' 
     312        redirect(URL('search.html')) 
     313    return dict(form=form) 
     314 
    301315# Validation for existing closure button 
    302316# If user selected Yes (it's existing incident) then they must select a closure ID 
     
    347361            result = result + "#"+item + " " 
    348362        result = result + "of " + lanecount 
    349     return result  
     363    return result 
Note: See TracChangeset for help on using the changeset viewer.