From 56e1deccc0d0a5ba290873d1464441e839a94086 Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 27 Jul 2023 22:20:40 +0200 Subject: [PATCH] fix error w/ clippy --- src/tera/log.rs | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/tera/log.rs b/src/tera/log.rs index e5bfaf9..e70af42 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -34,7 +34,7 @@ impl<'r> FromRequest<'r> for KioskCookie { } } -#[get("/", rank=2)] +#[get("/", rank = 2)] async fn index( db: &State, flash: Option>, @@ -68,7 +68,7 @@ async fn index( #[get("/kiosk/ekrv2019")] fn new_kiosk(cookies: &CookieJar<'_>) -> Redirect { - let mut cookie = Cookie::new("kiosk", format!("yes")); + let mut cookie = Cookie::new("kiosk", "yes".to_string()); cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12)); cookies.add_private(cookie); Redirect::to("/log") @@ -105,7 +105,7 @@ async fn kiosk( Template::render("kiosk", context.into_json()) } -async fn create_logbook(db: &SqlitePool, data: Form) -> Flash{ +async fn create_logbook(db: &SqlitePool, data: Form) -> Flash { match Logbook::create( db, data.into_inner() @@ -121,7 +121,6 @@ async fn create_logbook(db: &SqlitePool, data: Form) -> Flash Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")), } - } #[post("/", data = "", rank = 2)] @@ -134,11 +133,20 @@ async fn create( } #[post("/", data = "")] -async fn create_kiosk(db: &State, data: Form, _kiosk: KioskCookie) -> Flash { +async fn create_kiosk( + db: &State, + data: Form, + _kiosk: KioskCookie, +) -> Flash { create_logbook(db, data).await } -async fn home_logbook(db: &SqlitePool, data: Form, logbook_id: i32, user: &User) -> Flash{ +async fn home_logbook( + db: &SqlitePool, + data: Form, + logbook_id: i32, + user: &User, +) -> Flash { let logbook: Option = Logbook::find_by_id(db, logbook_id).await; let Some(logbook) = logbook else { return Flash::error( @@ -155,7 +163,6 @@ async fn home_logbook(db: &SqlitePool, data: Form, logbook_id: i3 format!("Logbook with ID {} could not be updated!", logbook_id), ), } - } #[post("/", data = "")] @@ -163,10 +170,18 @@ async fn home_kiosk( db: &State, data: Form, logbook_id: i32, - _kiosk: KioskCookie + _kiosk: KioskCookie, ) -> Flash { let logbook = Logbook::find_by_id(db, logbook_id).await.unwrap(); //TODO: fixme - home_logbook(db, data, logbook_id, &User::find_by_id(db, logbook.shipmaster as i32).await.unwrap()).await + home_logbook( + db, + data, + logbook_id, + &User::find_by_id(db, logbook.shipmaster as i32) + .await + .unwrap(), + ) + .await } #[post("/", data = "", rank = 2)]