diff --git a/app.py b/app.py index 84d4ed2..c47d513 100755 --- a/app.py +++ b/app.py @@ -36,8 +36,17 @@ def inject_stage_and_region(): return dict(calibration=get_calibration(conn), CalibrationState=db.CalibrationState) +@app.before_request +def manage_auto_use_last_calibration(): + if config.AUTO_USE_LAST_CALIBRATION and 'calibration_id' not in session: + conn = db.get() + last = db.Calibration.get_last(conn) + if last is not None: + session['calibration_id'] = last.id + + @app.route("/") -def hello_world(): +def index(): conn = db.get() objects = db.Object.all(conn) return render_template('index.html', objects=objects) diff --git a/config.py b/config.py index b43f359..3947dac 100644 --- a/config.py +++ b/config.py @@ -5,7 +5,8 @@ BACKUPS_DIR = 'data-backups' CALIBRATION_DIR = join(DATA_DIR, 'calibrations') OBJECT_DIR = join(DATA_DIR, 'objects') DATABASE_PATH = join(DATA_DIR, 'db.sqlite') -SECRET_KEY = 'tobedefined' + +AUTO_USE_LAST_CALIBRATION = False LEDS_UUIDS = [ 'ac59350e-3787-46d2-88fa-743c1d34fe86',