Compare commits

...

9 Commits

Author SHA1 Message Date
504d237405 swag 2026-02-25 15:53:41 +00:00
6696bcc4e7 a 2026-02-25 15:36:18 +00:00
32a1458218 a 2026-02-25 15:33:42 +00:00
4697086f86 a 2026-02-25 15:32:36 +00:00
c4b9e5f360 w 2026-02-25 15:14:30 +00:00
0a9934b889 b 2026-02-25 15:14:07 +00:00
8ad1650079 a 2026-02-25 15:13:51 +00:00
6e50013a84 swag 2026-02-25 15:03:45 +00:00
dba9a7690d a 2026-02-25 14:59:35 +00:00
3 changed files with 15 additions and 7 deletions

View File

@@ -24,6 +24,10 @@ CREATE TABLE IF NOT EXISTS val (
default_time TEXT NOT NULL DEFAULT '21:00'
)
""")
cursor.execute("SELECT COUNT(*) FROM val")
count = cursor.fetchone()[0]
if count == 0:
cursor.execute("INSERT INTO val (default_time) VALUES (?)", ('21:00',))
conn.commit()
conn.close()
@@ -39,7 +43,8 @@ def mainpage():
cursor.execute("SELECT name, time, noshutdown FROM items ORDER BY name")
items = cursor.fetchall()
cursor.execute("SELECT default_time FROM val")
default_time = cursor.fetchone()
default_time_row = cursor.fetchone()
default_time = default_time_row[0] if default_time_row else '21:00'
conn.close()
return render_template('index.html', title='BS Shutdown', items=items, default_time=default_time)
@@ -71,7 +76,7 @@ def submit():
@app.route("/submit-default", methods=["POST"])
def submit_default():
time_value = request.form.get("time-select")
time_value = request.form.get("default-time")
conn = get_db_connection()
cursor = conn.cursor()
if bool(pattern.match(time_value)) is not True:

View File

@@ -42,7 +42,10 @@
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link {% if title=='BG Shutdown' %}active{% endif %}" href="{{ url_for('mainpage') }}">Accueil</a>
<a class="nav-link {% if title=='BS Shutdown' %}active{% endif %}" href="{{ url_for('mainpage') }}">Accueil</a>
</li>
<li class="nav-item">
<a class="nav-link {% if title=='BG Shutdown' %}active{% endif %}" href="{{ url_for('mainpage') }}">Groupes</a>
</li>
</ul>
</div>

View File

@@ -10,14 +10,14 @@
<div class="col-10">
<form method="post" action="/submit" class="row g-2 align-items-center">
<div class="col-md-3">
<div class="col-md-2">
<input
type="text"
name="query"
class="form-control bg-dark text-white"
placeholder="Nom de la machine">
</div>
<div class="col-md-3">
<div class="col-md-2">
<select name="time" class="form-select bg-dark text-white" id="time-select">
{% for hour in range(0, 24) %}
<option value="{{ '%02d:00'|format(hour) }}">{{ '%02d:00'|format(hour) }}</option>
@@ -40,7 +40,7 @@
</div>
<div class="col-auto gap-1 ms-auto">
<form method="post" action="/submit-default" class="d-flex gap-1">
<form method="post" action="/submit-default" class="d-flex align-items-center gap-1">
<select name="default-time" class="form-select bg-dark text-white flex-grow-1" id="default-time-select">
{% for hour in range(0, 24) %}
{% set h1 = '%02d:00'|format(hour) %}
@@ -57,7 +57,7 @@
</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-sm btn-primary">
<button type="submit" class="btn btn-sm btn-primary w-100">
<i class="bi bi-save"> Save</i>
</button>
</form>