clippy clean

This commit is contained in:
philipp 2023-07-27 14:40:05 +02:00
parent 38300d826a
commit 1733fc7fe7

View File

@ -1,9 +1,13 @@
use rocket::{
form::Form,
get, post,
request::{FlashMessage, FromRequest, self},
get,
http::{Cookie, CookieJar},
post,
request::{self, FlashMessage, FromRequest},
response::{Flash, Redirect},
routes, Route, State, Request, http::{CookieJar, Cookie}, time::{OffsetDateTime, Duration},
routes,
time::{Duration, OffsetDateTime},
Request, Route, State,
};
use rocket_dyn_templates::Template;
use sqlx::SqlitePool;
@ -62,12 +66,8 @@ async fn index(
Template::render("log", context.into_json())
}
#[get("/kiosk/ekrv2019")]
fn new_kiosk(
flash: Option<FlashMessage<'_>>,
cookies: &CookieJar<'_>,
) -> Redirect {
fn new_kiosk(cookies: &CookieJar<'_>) -> Redirect {
let mut cookie = Cookie::new("kiosk", format!("yes"));
cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12));
cookies.add_private(cookie);
@ -75,7 +75,11 @@ fn new_kiosk(
}
#[get("/kiosk")]
async fn kiosk(db: &State<SqlitePool>, flash: Option<FlashMessage<'_>>, _kiosk: KioskCookie) -> Template {
async fn kiosk(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
_kiosk: KioskCookie,
) -> Template {
let boats = Boat::all(db).await;
let coxes = User::cox(db).await;
let users = User::all(db).await;
@ -122,10 +126,7 @@ async fn create(
}
#[post("/", data = "<data>")]
async fn create_kiosk(
db: &State<SqlitePool>,
data: Form<LogToAdd>,
) -> Flash<Redirect> {
async fn create_kiosk(db: &State<SqlitePool>, data: Form<LogToAdd>) -> Flash<Redirect> {
match Logbook::create(
db,
data.into_inner()
@ -140,7 +141,6 @@ async fn create_kiosk(
}
}
#[post("/<logbook_id>", data = "<data>")]
async fn home_kiosk(
db: &State<SqlitePool>,
@ -155,7 +155,16 @@ async fn home_kiosk(
)
};
match logbook.home(db, &User::find_by_id(db, logbook.shipmaster as i32).await.unwrap(), data.into_inner()).await {
match logbook
.home(
db,
&User::find_by_id(db, logbook.shipmaster as i32)
.await
.unwrap(),
data.into_inner(),
)
.await
{
Ok(_) => Flash::success(Redirect::to("/log"), "Successfully updated log"),
Err(_) => Flash::error(
Redirect::to("/log"),
@ -164,7 +173,6 @@ async fn home_kiosk(
}
}
#[post("/<logbook_id>", data = "<data>", rank = 2)]
async fn home(
db: &State<SqlitePool>,
@ -190,7 +198,15 @@ async fn home(
}
pub fn routes() -> Vec<Route> {
routes![index, create, create_kiosk, home, kiosk, home_kiosk, new_kiosk]
routes![
index,
create,
create_kiosk,
home,
kiosk,
home_kiosk,
new_kiosk
]
}
#[cfg(test)]