clean db
This commit is contained in:
@ -205,6 +205,28 @@ async fn home(
|
||||
home_logbook(db, data, logbook_id, &adminuser.user).await
|
||||
}
|
||||
|
||||
#[get("/<logbook_id>/delete")]
|
||||
async fn delete(
|
||||
db: &State<SqlitePool>,
|
||||
flash: Option<FlashMessage<'_>>,
|
||||
logbook_id: i32,
|
||||
_adminuser: AdminUser,
|
||||
) -> Flash<Redirect> {
|
||||
let logbook = Logbook::find_by_id(db, logbook_id).await;
|
||||
if let Some(logbook) = logbook {
|
||||
logbook.delete(db).await;
|
||||
Flash::success(
|
||||
Redirect::to("/log"),
|
||||
format!("Logbook with ID {} successfully deleted!", logbook_id),
|
||||
)
|
||||
} else {
|
||||
Flash::error(
|
||||
Redirect::to("/log"),
|
||||
format!("Logbook with ID {} could not be found!", logbook_id),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![
|
||||
index,
|
||||
@ -215,7 +237,8 @@ pub fn routes() -> Vec<Route> {
|
||||
home_kiosk,
|
||||
new_kiosk,
|
||||
show,
|
||||
show_kiosk
|
||||
show_kiosk,
|
||||
delete
|
||||
]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user