clean code with clippy
This commit is contained in:
@@ -4,22 +4,22 @@ use rocket::{
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{planned_event::PlannedEvent, tripdetails::TripDetails, user::AdminUser};
|
||||
use crate::model::{
|
||||
planned_event::PlannedEvent,
|
||||
tripdetails::{TripDetails, TripDetailsToAdd},
|
||||
user::AdminUser,
|
||||
};
|
||||
|
||||
//TODO: add constraints (e.g. planned_amount_cox > 0)
|
||||
#[derive(FromForm)]
|
||||
#[derive(FromForm, Serialize)]
|
||||
struct AddPlannedEventForm<'r> {
|
||||
day: &'r str,
|
||||
name: &'r str,
|
||||
planned_amount_cox: i32,
|
||||
allow_guests: bool,
|
||||
planned_starting_time: &'r str,
|
||||
max_people: i32,
|
||||
always_show: bool,
|
||||
notes: Option<&'r str>,
|
||||
trip_type: Option<i64>,
|
||||
#[serde(flatten)]
|
||||
tripdetails: TripDetailsToAdd<'r>,
|
||||
}
|
||||
|
||||
#[post("/planned-event", data = "<data>")]
|
||||
@@ -28,17 +28,9 @@ async fn create(
|
||||
data: Form<AddPlannedEventForm<'_>>,
|
||||
_admin: AdminUser,
|
||||
) -> 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 data = data.into_inner();
|
||||
|
||||
let trip_details_id = TripDetails::create(db, data.tripdetails).await;
|
||||
|
||||
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc. we
|
||||
//just created
|
||||
|
Reference in New Issue
Block a user