diff --git a/src/tera/log.rs b/src/tera/log.rs index a9178a5..fc4acba 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -162,6 +162,15 @@ async fn create_logbook( data: Form, user: &NonGuestUser, ) -> Flash { + Log::create( + db, + format!( + "User {} tries to create log entry={:?}", + user.user.name, data + ), + ) + .await; + match Logbook::create( db, data.into_inner(), @@ -202,6 +211,15 @@ async fn create_kiosk( _kiosk: KioskCookie, ) -> Flash { let creator = User::find_by_id(db, data.shipmaster as i32).await.unwrap(); + Log::create( + db, + format!( + "Kiosk tries to create log for shipmaster {} entry={:?}", + creator.name, data + ), + ) + .await; + create_logbook(db, data, &NonGuestUser::try_from(creator).unwrap()).await //TODO: fixme } @@ -237,6 +255,13 @@ async fn home_kiosk( _kiosk: KioskCookie, ) -> Flash { let logbook = Logbook::find_by_id(db, logbook_id).await.unwrap(); //TODO: fixme + + Log::create( + db, + format!("Kiosk tries to finish log entry {logbook_id} {data:?}"), + ) + .await; + home_logbook( db, data, @@ -258,6 +283,15 @@ async fn home( logbook_id: i32, user: NonGuestUser, ) -> Flash { + Log::create( + db, + format!( + "User {} tries to finish log entry {logbook_id} {data:?}", + user.user.name + ), + ) + .await; + home_logbook(db, data, logbook_id, &user).await } @@ -265,6 +299,11 @@ async fn home( async fn delete(db: &State, logbook_id: i32, user: User) -> Flash { let logbook = Logbook::find_by_id(db, logbook_id).await; if let Some(logbook) = logbook { + Log::create( + db, + format!("User {} tries to delete log entry {logbook_id}", user.name), + ) + .await; match logbook.delete(db, &user).await { Ok(_) => Flash::success( Redirect::to("/log"), @@ -294,6 +333,7 @@ async fn delete_kiosk( let cox = User::find_by_id(db, logbook.shipmaster as i32) .await .unwrap(); + Log::create(db, format!("Kiosk tries to delete log entry {logbook_id} ")).await; match logbook.delete(db, &cox).await { Ok(_) => Flash::success( Redirect::to("/log"),