functionele logs toegevoegd in seed.py AT

This commit is contained in:
Anh-Thy04
2025-05-27 16:01:19 +02:00
parent 8c0877d7eb
commit 42ea35bd47
3 changed files with 13 additions and 7 deletions

View File

@@ -1,7 +1,13 @@
from application import db, app
from application.dashboard.models import AllowedPlate
from application.dashboard.models import AllowedPlate, LoggedItem, datetime
with app.app_context():
AllowedPlate.query.delete()
db.session.add(AllowedPlate("MUN389"))
db.session.commit()
with app.app_context():
LoggedItem.query.delete()
db.session.add(LoggedItem("MUN389", datetime.now(), True))
db.session.add(LoggedItem("MUN389", datetime.now(), False))
db.session.commit()

View File

@@ -23,13 +23,13 @@
</tr>
</thead>
<tbody>
{% for form in recent_logs %}
{% for log in logs %}
<tr>
<td><small class="fs-6">{{ form.timestamp.strftime('%H:%M:%S') }}</small></td>
<td><small class="fs-6">{{ plate.plate }}</small></td>
<td><small class="fs-6">{{ log.dateLogged.strftime('%H:%M:%S') }}</small></td>
<td><small class="fs-6">{{ log.plate }}</small></td>
<td>
<span class="badge {% if log.status == 'success' %}bg-success{% elif log.status == 'warning' %}bg-warning{% elif log.status == 'error' %}bg-danger{% else %}bg-secondary{% endif %} fs-6">
{{ form.allowed }}
{{ log.allowed }}
</span>
</td>
</tr>

View File

@@ -12,8 +12,8 @@ dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
#@login_required
def dashboard():
Plates = AllowedPlate.query.all()
recent_logs = LoggedItem.query.order_by(LoggedItem.dateLogged.desc()).limit(50).all()
return render_template("dashboard.html", plates=Plates, recent_logs=recent_logs)
logs = LoggedItem.query.order_by(LoggedItem.dateLogged.desc()).limit(50).all()
return render_template("dashboard.html", plates=Plates, logs=logs)
@dash_blueprint.route('/add', methods=['GET', 'POST'])