many updates :-(
All checks were successful
CI/CD Pipeline / test (push) Successful in 11m12s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-09-03 21:35:43 +03:00
parent 96dcf2c4ae
commit f38d506fe4
9 changed files with 82 additions and 45 deletions

View File

@ -4,6 +4,7 @@ use sqlx::SqlitePool;
use super::{
event::{Event, Registration},
log::Log,
notification::Notification,
tripdetails::TripDetails,
triptype::TripType,
@ -329,18 +330,16 @@ WHERE day=?
return Err(TripDeleteError::SomebodyAlreadyRegistered);
}
if !self.is_trip_from_user(user.id) {
if !self.is_trip_from_user(user.id) && !user.has_role(db, "admin").await {
return Err(TripDeleteError::NotYourTrip);
}
sqlx::query!(
"DELETE FROM trip WHERE cox_id = ? AND id = ?",
user.id,
self.id
)
.execute(db)
.await
.unwrap(); //TODO: fixme
Log::create(db, format!("{} deleted trip: {:#?}", user.user.name, self)).await;
sqlx::query!("DELETE FROM trip WHERE id = ?", self.id)
.execute(db)
.await
.unwrap(); //TODO: fixme
Ok(())
}