fix error w/ clippy

This commit is contained in:
philipp 2023-07-27 22:20:40 +02:00
parent 2e9ad2215f
commit 56e1deccc0

View File

@ -34,7 +34,7 @@ impl<'r> FromRequest<'r> for KioskCookie {
} }
} }
#[get("/", rank=2)] #[get("/", rank = 2)]
async fn index( async fn index(
db: &State<SqlitePool>, db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>, flash: Option<FlashMessage<'_>>,
@ -68,7 +68,7 @@ async fn index(
#[get("/kiosk/ekrv2019")] #[get("/kiosk/ekrv2019")]
fn new_kiosk(cookies: &CookieJar<'_>) -> Redirect { fn new_kiosk(cookies: &CookieJar<'_>) -> Redirect {
let mut cookie = Cookie::new("kiosk", format!("yes")); let mut cookie = Cookie::new("kiosk", "yes".to_string());
cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12)); cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12));
cookies.add_private(cookie); cookies.add_private(cookie);
Redirect::to("/log") Redirect::to("/log")
@ -105,7 +105,7 @@ async fn kiosk(
Template::render("kiosk", context.into_json()) Template::render("kiosk", context.into_json())
} }
async fn create_logbook(db: &SqlitePool, data: Form<LogToAdd>) -> Flash<Redirect>{ async fn create_logbook(db: &SqlitePool, data: Form<LogToAdd>) -> Flash<Redirect> {
match Logbook::create( match Logbook::create(
db, db,
data.into_inner() data.into_inner()
@ -121,7 +121,6 @@ async fn create_logbook(db: &SqlitePool, data: Form<LogToAdd>) -> Flash<Redirect
Err(LogbookCreateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")), Err(LogbookCreateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")),
} }
} }
#[post("/", data = "<data>", rank = 2)] #[post("/", data = "<data>", rank = 2)]
@ -134,11 +133,20 @@ async fn create(
} }
#[post("/", data = "<data>")] #[post("/", data = "<data>")]
async fn create_kiosk(db: &State<SqlitePool>, data: Form<LogToAdd>, _kiosk: KioskCookie) -> Flash<Redirect> { async fn create_kiosk(
db: &State<SqlitePool>,
data: Form<LogToAdd>,
_kiosk: KioskCookie,
) -> Flash<Redirect> {
create_logbook(db, data).await create_logbook(db, data).await
} }
async fn home_logbook(db: &SqlitePool, data: Form<LogToFinalize>, logbook_id: i32, user: &User) -> Flash<Redirect>{ async fn home_logbook(
db: &SqlitePool,
data: Form<LogToFinalize>,
logbook_id: i32,
user: &User,
) -> Flash<Redirect> {
let logbook: Option<Logbook> = Logbook::find_by_id(db, logbook_id).await; let logbook: Option<Logbook> = Logbook::find_by_id(db, logbook_id).await;
let Some(logbook) = logbook else { let Some(logbook) = logbook else {
return Flash::error( return Flash::error(
@ -155,7 +163,6 @@ async fn home_logbook(db: &SqlitePool, data: Form<LogToFinalize>, logbook_id: i3
format!("Logbook with ID {} could not be updated!", logbook_id), format!("Logbook with ID {} could not be updated!", logbook_id),
), ),
} }
} }
#[post("/<logbook_id>", data = "<data>")] #[post("/<logbook_id>", data = "<data>")]
@ -163,10 +170,18 @@ async fn home_kiosk(
db: &State<SqlitePool>, db: &State<SqlitePool>,
data: Form<LogToFinalize>, data: Form<LogToFinalize>,
logbook_id: i32, logbook_id: i32,
_kiosk: KioskCookie _kiosk: KioskCookie,
) -> Flash<Redirect> { ) -> Flash<Redirect> {
let logbook = Logbook::find_by_id(db, logbook_id).await.unwrap(); //TODO: fixme let logbook = Logbook::find_by_id(db, logbook_id).await.unwrap(); //TODO: fixme
home_logbook(db, data, logbook_id, &User::find_by_id(db, logbook.shipmaster as i32).await.unwrap()).await home_logbook(
db,
data,
logbook_id,
&User::find_by_id(db, logbook.shipmaster as i32)
.await
.unwrap(),
)
.await
} }
#[post("/<logbook_id>", data = "<data>", rank = 2)] #[post("/<logbook_id>", data = "<data>", rank = 2)]