Compare commits
No commits in common. "830aa58e7b6f236649b1fa2c7fda52393b8de8b3" and "d819462b0d6a3ba912d4845d2f5ae066b746d639" have entirely different histories.
830aa58e7b
...
d819462b0d
@ -240,29 +240,11 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id",
|
|||||||
.unwrap(); //Okay, as planned_event can only be created with proper DB backing
|
.unwrap(); //Okay, as planned_event can only be created with proper DB backing
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete(&self, db: &SqlitePool) -> Result<(), String> {
|
pub async fn delete(&self, db: &SqlitePool) {
|
||||||
if Registration::all_rower(db, self.trip_details_id)
|
|
||||||
.await
|
|
||||||
.len()
|
|
||||||
> 0
|
|
||||||
{
|
|
||||||
return Err(
|
|
||||||
"Event kann nicht gelöscht werden, weil mind. 1 Ruderer angemeldet ist.".into(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if Registration::all_cox(db, self.trip_details_id).await.len() > 0 {
|
|
||||||
return Err(
|
|
||||||
"Event kann nicht gelöscht werden, weil mind. 1 Steuerperson angemeldet ist."
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlx::query!("DELETE FROM planned_event WHERE id = ?", self.id)
|
sqlx::query!("DELETE FROM planned_event WHERE id = ?", self.id)
|
||||||
.execute(db)
|
.execute(db)
|
||||||
.await
|
.await
|
||||||
.unwrap(); //Okay, as PlannedEvent can only be created with proper DB backing
|
.unwrap(); //Okay, as PlannedEvent can only be created with proper DB backing
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_ics_feed(db: &SqlitePool) -> String {
|
pub async fn get_ics_feed(db: &SqlitePool) -> String {
|
||||||
|
@ -78,13 +78,12 @@ async fn update(
|
|||||||
|
|
||||||
#[get("/planned-event/<id>/delete")]
|
#[get("/planned-event/<id>/delete")]
|
||||||
async fn delete(db: &State<SqlitePool>, id: i64, _admin: PlannedEventUser) -> Flash<Redirect> {
|
async fn delete(db: &State<SqlitePool>, id: i64, _admin: PlannedEventUser) -> Flash<Redirect> {
|
||||||
let Some(event) = PlannedEvent::find_by_id(db, id).await else {
|
match PlannedEvent::find_by_id(db, id).await {
|
||||||
return Flash::error(Redirect::to("/planned"), "PlannedEvent does not exist");
|
Some(planned_event) => {
|
||||||
};
|
planned_event.delete(db).await;
|
||||||
|
Flash::success(Redirect::to("/planned"), "Event gelöscht")
|
||||||
match event.delete(db).await {
|
}
|
||||||
Ok(()) => Flash::success(Redirect::to("/planned"), "Event gelöscht"),
|
None => Flash::error(Redirect::to("/planned"), "PlannedEvent does not exist"),
|
||||||
Err(e) => Flash::error(Redirect::to("/planned"), e),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user