This commit is contained in:
Thomas Forgione 2024-07-07 23:22:02 +02:00
parent 28051e0ff4
commit 8db80625be
3 changed files with 27 additions and 9 deletions

13
db.py
View File

@ -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()

View File

@ -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
);

View File

@ -6,10 +6,22 @@
<h1 class="title">{{ object.name }}</h1>
<div class="field is-grouped is-grouped-multiline">
<div class="control">
{% if object.calibrated == 0 %}
<span class="tags has-addons">
<span class="tag is-dark">étalonnage</span>
<span class="tag is-danger">données manquantes</span>
</span>
{% elif object.calibrated == 1 %}
<span class="tags has-addons">
<span class="tag is-dark">étalonnage</span>
<span class="tag is-warning">pas fait</span>
</span>
{% elif object.calibrated == 2 %}
<a href="/calibration/{{ object.id }}" class="tags has-addons">
<span class="tag is-dark">étalonnage</span>
<span class="tag is-success">fait</span>
</a>
{% endif %}
</div>
</div>
</div>