Compare commits

...

2 Commits

Author SHA1 Message Date
4da996251a Merge pull request 'better logs' (#637) from update-logbook-entries into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m43s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 6m13s
Reviewed-on: #637
2024-07-23 15:15:16 +02:00
aa9568f326 better logs
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2024-07-23 15:13:36 +02:00

View File

@ -288,23 +288,28 @@ async fn update(
data: Form<LogToUpdate>, data: Form<LogToUpdate>,
user: VorstandUser, user: VorstandUser,
) -> Flash<Redirect> { ) -> Flash<Redirect> {
Log::create(
db,
format!("User {} tries to update log entry={:?}", &user.name, data),
)
.await;
let data = data.into_inner(); let data = data.into_inner();
let Some(logbook) = Logbook::find_by_id(db, data.id).await else { 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)); 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 { match logbook.update(db, data.clone(), &user.0).await {
Ok(()) => Flash::success( Ok(()) => {
Redirect::to("/log/show"), Log::create(
format!("Logbucheintrag erfolgreich bearbeitet"), 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( Err(LogbookAdminUpdateError::NotAllowed) => Flash::error(
Redirect::to("/log/show"), Redirect::to("/log/show"),
format!("Du hast keine Erlaubnis, diesen Logbucheintrag zu bearbeiten!"), format!("Du hast keine Erlaubnis, diesen Logbucheintrag zu bearbeiten!"),