From 2e80f7bc3833998fc77a6768d481c891d073dbd6 Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 30 Jul 2023 14:13:49 +0200 Subject: [PATCH] add logbook history --- src/tera/log.rs | 20 ++++++++++++++++++-- templates/includes/macros.html.tera | 4 ++++ templates/log.completed.html.tera | 16 ++++++++++++++++ templates/log.html.tera | 6 ------ 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 templates/log.completed.html.tera diff --git a/src/tera/log.rs b/src/tera/log.rs index 5954666..6715f1e 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -9,7 +9,7 @@ use rocket::{ time::{Duration, OffsetDateTime}, Request, Route, State, }; -use rocket_dyn_templates::Template; +use rocket_dyn_templates::{context, Template}; use sqlx::SqlitePool; use tera::Context; @@ -64,6 +64,20 @@ async fn index( Template::render("log", context.into_json()) } +#[get("/show", rank = 2)] +async fn show(db: &State, user: User) -> Template { + let logs = Logbook::completed(db).await; + + Template::render("log.completed", context!(logs, loggedin_user: &user)) +} + +#[get("/show")] +async fn show_kiosk(db: &State, _kios: KioskCookie) -> Template { + let logs = Logbook::completed(db).await; + + Template::render("log.completed", context!(logs)) +} + #[get("/kiosk/ekrv2019")] fn new_kiosk(cookies: &CookieJar<'_>) -> Redirect { let mut cookie = Cookie::new("kiosk", "yes".to_string()); @@ -198,7 +212,9 @@ pub fn routes() -> Vec { home, kiosk, home_kiosk, - new_kiosk + new_kiosk, + show, + show_kiosk ] } diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 08fd677..1a15567 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -17,6 +17,10 @@ STATS Logbuch + + LGBUCH HISTORY + Logbuch History + LOGBUCH Logbuch diff --git a/templates/log.completed.html.tera b/templates/log.completed.html.tera new file mode 100644 index 0000000..b097213 --- /dev/null +++ b/templates/log.completed.html.tera @@ -0,0 +1,16 @@ +{% import "includes/macros" as macros %} +{% import "includes/forms/log" as log %} + +{% extends "base" %} + +{% block content %} + +
+

Logbuch

+ {% for log in logs %} + {{ log::show(log=log, state="completed", only_ones=false) }} +
+ {% endfor %} +
+ +{% endblock content%} diff --git a/templates/log.html.tera b/templates/log.html.tera index 63f8c95..3df319b 100644 --- a/templates/log.html.tera +++ b/templates/log.html.tera @@ -22,12 +22,6 @@ {% endif %}
{% endfor %} - -

Einträge

- {% for log in completed %} - {{ log::show(log=log, state="completed", only_ones=false) }} -
- {% endfor %} {% endblock content%}