From 8db80625beac4d333e37a666485edc0756255908 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Sun, 7 Jul 2024 23:22:02 +0200 Subject: [PATCH] Working --- db.py | 13 +++++++++---- schema.sql | 3 ++- templates/object.html | 20 ++++++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/db.py b/db.py index a1091bb..c1a7313 100755 --- a/db.py +++ b/db.py @@ -46,18 +46,23 @@ if __name__ == '__main__': class Object: @staticmethod def select_args() -> str: - return 'id, name' + return 'id, name, calibrated' - def __init__(self, object_id: int, name: str): + def __init__(self, object_id: int, name: str, calibrated: int): self.id = object_id self.name = name + # 0 means no data available + # 1 means data available but calibration not done + # 2 means calibration done + self.calibrated = calibrated + @staticmethod def create(name: str, db: sqlite3.Connection) -> 'Object': cur = db.cursor() response = cur.execute( - 'INSERT INTO object(name) VALUES (?) RETURNING ' + Object.select_args() + ';', - [name] + 'INSERT INTO object(name, calibrated) VALUES (?, ?) RETURNING ' + Object.select_args() + ';', + [name, 0] ) return response.fetchone() diff --git a/schema.sql b/schema.sql index f9cc648..2b8db13 100644 --- a/schema.sql +++ b/schema.sql @@ -2,5 +2,6 @@ DROP TABLE IF EXISTS object; CREATE TABLE object ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL + name TEXT NOT NULL, + calibrated INT NOT NULL ); diff --git a/templates/object.html b/templates/object.html index 43068cd..8216640 100644 --- a/templates/object.html +++ b/templates/object.html @@ -6,10 +6,22 @@

{{ object.name }}

- - étalonnage - fait - + {% if object.calibrated == 0 %} + + étalonnage + données manquantes + + {% elif object.calibrated == 1 %} + + étalonnage + pas fait + + {% elif object.calibrated == 2 %} + + étalonnage + fait + + {% endif %}