even more tests!

This commit is contained in:
2023-04-26 12:21:30 +02:00
parent 1e92b166c7
commit a49de71a5d
7 changed files with 155 additions and 44 deletions

View File

@ -51,9 +51,13 @@ async fn create(
#[get("/planned-event/<id>/delete")]
async fn delete(db: &State<SqlitePool>, id: i64, _admin: AdminUser) -> Flash<Redirect> {
PlannedEvent::delete(db, id).await;
Flash::success(Redirect::to("/"), "Successfully deleted the event")
match PlannedEvent::find_by_id(db, id).await {
Some(planned_event) => {
planned_event.delete(db).await;
Flash::success(Redirect::to("/"), "Successfully deleted the event")
}
None => Flash::error(Redirect::to("/"), "PlannedEvent does not exist"),
}
}
pub fn routes() -> Vec<Route> {

View File

@ -72,6 +72,9 @@ async fn join(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash
Err(UserTripError::AlreadyRegisteredAsCox) => {
Flash::error(Redirect::to("/"), "Du hilfst bereits als Steuerperson aus!")
}
Err(UserTripError::TripDetailsNotFound) => {
Flash::error(Redirect::to("/"), "Trip_details do not exist.")
}
}
}