Merge pull request 'better logs' (#637) from update-logbook-entries into main
Reviewed-on: #637
This commit is contained in:
commit
4da996251a
@ -288,23 +288,28 @@ async fn update(
|
||||
data: Form<LogToUpdate>,
|
||||
user: VorstandUser,
|
||||
) -> Flash<Redirect> {
|
||||
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!"),
|
||||
|
Loading…
Reference in New Issue
Block a user