From aa9568f3262e2daac0850f091c3ced4f6bdf0d57 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 23 Jul 2024 15:13:36 +0200 Subject: [PATCH] better logs --- src/tera/log.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/tera/log.rs b/src/tera/log.rs index ccca5fd..3727c81 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -288,23 +288,28 @@ async fn update( data: Form, user: VorstandUser, ) -> Flash { - Log::create( - db, - format!("User {} tries to update log entry={:?}", &user.name, data), - ) - .await; - let data = data.into_inner(); let Some(logbook) = Logbook::find_by_id(db, data.id).await else { return Flash::error(Redirect::to("/log"), &format!("Logbucheintrag kann nicht bearbeitet werden, da es einen Logbuch-Eintrag mit ID={} nicht gibt", data.id)); }; - match logbook.update(db, data, &user.0).await { - Ok(()) => Flash::success( - Redirect::to("/log/show"), - format!("Logbucheintrag erfolgreich bearbeitet"), - ), + match logbook.update(db, data.clone(), &user.0).await { + Ok(()) => { + Log::create( + db, + format!( + "User {} updated log entry={:?} to {:?}", + &user.name, logbook, data + ), + ) + .await; + + Flash::success( + Redirect::to("/log/show"), + format!("Logbucheintrag erfolgreich bearbeitet"), + ) + } Err(LogbookAdminUpdateError::NotAllowed) => Flash::error( Redirect::to("/log/show"), format!("Du hast keine Erlaubnis, diesen Logbucheintrag zu bearbeiten!"),