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(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
@ -68,7 +68,7 @@ async fn index(
#[get("/kiosk/ekrv2019")]
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));
cookies.add_private(cookie);
Redirect::to("/log")
@ -105,7 +105,7 @@ async fn kiosk(
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(
db,
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)")),
}
}
#[post("/", data = "<data>", rank = 2)]
@ -134,11 +133,20 @@ async fn create(
}
#[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
}
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 Some(logbook) = logbook else {
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),
),
}
}
#[post("/<logbook_id>", data = "<data>")]
@ -163,10 +170,18 @@ async fn home_kiosk(
db: &State<SqlitePool>,
data: Form<LogToFinalize>,
logbook_id: i32,
_kiosk: KioskCookie
_kiosk: KioskCookie,
) -> Flash<Redirect> {
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)]