Auto use last calibration mode

This commit is contained in:
Thomas Forgione 2024-07-15 16:56:13 +02:00
parent ed4a448016
commit c7903ef4b5
2 changed files with 12 additions and 2 deletions

11
app.py
View File

@ -36,8 +36,17 @@ def inject_stage_and_region():
return dict(calibration=get_calibration(conn), CalibrationState=db.CalibrationState) 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("/") @app.route("/")
def hello_world(): def index():
conn = db.get() conn = db.get()
objects = db.Object.all(conn) objects = db.Object.all(conn)
return render_template('index.html', objects=objects) return render_template('index.html', objects=objects)

View File

@ -5,7 +5,8 @@ BACKUPS_DIR = 'data-backups'
CALIBRATION_DIR = join(DATA_DIR, 'calibrations') CALIBRATION_DIR = join(DATA_DIR, 'calibrations')
OBJECT_DIR = join(DATA_DIR, 'objects') OBJECT_DIR = join(DATA_DIR, 'objects')
DATABASE_PATH = join(DATA_DIR, 'db.sqlite') DATABASE_PATH = join(DATA_DIR, 'db.sqlite')
SECRET_KEY = 'tobedefined'
AUTO_USE_LAST_CALIBRATION = False
LEDS_UUIDS = [ LEDS_UUIDS = [
'ac59350e-3787-46d2-88fa-743c1d34fe86', 'ac59350e-3787-46d2-88fa-743c1d34fe86',