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 %}