clean code with clippy

This commit is contained in:
2023-07-25 13:22:11 +02:00
parent 3765541674
commit a7789af713
10 changed files with 243 additions and 463 deletions

View File

@ -10,52 +10,29 @@ use crate::model::{
log::Log,
planned_event::PlannedEvent,
trip::{CoxHelpError, Trip, TripDeleteError, TripUpdateError},
tripdetails::TripDetails,
tripdetails::{TripDetails, TripDetailsToAdd},
user::CoxUser,
};
#[derive(FromForm)]
struct AddTripForm<'r> {
day: String,
//TODO: properly parse `planned_starting_time`
planned_starting_time: &'r str,
#[field(validate = range(1..))]
max_people: i32,
notes: Option<&'r str>,
trip_type: Option<i64>,
allow_guests: bool,
always_show: bool,
}
#[post("/trip", data = "<data>")]
async fn create(
db: &State<SqlitePool>,
data: Form<AddTripForm<'_>>,
data: Form<TripDetailsToAdd<'_>>,
cox: CoxUser,
) -> Flash<Redirect> {
let trip_details_id = TripDetails::create(
db,
data.planned_starting_time,
data.max_people,
&data.day,
data.notes,
data.allow_guests,
data.trip_type,
data.always_show,
)
.await;
let trip_details_id = TripDetails::create(db, data.into_inner()).await;
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just
//created
Trip::new_own(db, &cox, trip_details).await;
Trip::new_own(db, &cox, trip_details).await; //TODO: fix
Log::create(
db,
format!(
"Cox {} created trip on {} @ {} for {} rower",
cox.name, data.day, data.planned_starting_time, data.max_people,
),
)
.await;
//Log::create(
// db,
// format!(
// "Cox {} created trip on {} @ {} for {} rower",
// cox.name, trip_details.day, trip_details.planned_starting_time, trip_details.max_people,
// ),
//)
//.await;
Flash::success(Redirect::to("/"), "Ausfahrt erfolgreich erstellt.")
}
@ -402,7 +379,7 @@ mod test {
login.dispatch().await;
let req = client.get("/join/1");
let response = req.dispatch().await;
let _ = req.dispatch().await;
let req = client.get("/cox/join/1");
let response = req.dispatch().await;