forked from Ruderverein-Donau-Linz/rowt
clippy clean
This commit is contained in:
parent
38300d826a
commit
1733fc7fe7
@ -1,9 +1,13 @@
|
|||||||
use rocket::{
|
use rocket::{
|
||||||
form::Form,
|
form::Form,
|
||||||
get, post,
|
get,
|
||||||
request::{FlashMessage, FromRequest, self},
|
http::{Cookie, CookieJar},
|
||||||
|
post,
|
||||||
|
request::{self, FlashMessage, FromRequest},
|
||||||
response::{Flash, Redirect},
|
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 rocket_dyn_templates::Template;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
@ -62,12 +66,8 @@ async fn index(
|
|||||||
Template::render("log", context.into_json())
|
Template::render("log", context.into_json())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[get("/kiosk/ekrv2019")]
|
#[get("/kiosk/ekrv2019")]
|
||||||
fn new_kiosk(
|
fn new_kiosk(cookies: &CookieJar<'_>) -> Redirect {
|
||||||
flash: Option<FlashMessage<'_>>,
|
|
||||||
cookies: &CookieJar<'_>,
|
|
||||||
) -> Redirect {
|
|
||||||
let mut cookie = Cookie::new("kiosk", format!("yes"));
|
let mut cookie = Cookie::new("kiosk", format!("yes"));
|
||||||
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);
|
||||||
@ -75,7 +75,11 @@ fn new_kiosk(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/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 boats = Boat::all(db).await;
|
||||||
let coxes = User::cox(db).await;
|
let coxes = User::cox(db).await;
|
||||||
let users = User::all(db).await;
|
let users = User::all(db).await;
|
||||||
@ -101,7 +105,7 @@ async fn kiosk(db: &State<SqlitePool>, flash: Option<FlashMessage<'_>>, _kiosk:
|
|||||||
Template::render("kiosk", context.into_json())
|
Template::render("kiosk", context.into_json())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/", data = "<data>", rank=2)]
|
#[post("/", data = "<data>", rank = 2)]
|
||||||
async fn create(
|
async fn create(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<LogToAdd>,
|
data: Form<LogToAdd>,
|
||||||
@ -122,10 +126,7 @@ async fn create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/", data = "<data>")]
|
#[post("/", data = "<data>")]
|
||||||
async fn create_kiosk(
|
async fn create_kiosk(db: &State<SqlitePool>, data: Form<LogToAdd>) -> Flash<Redirect> {
|
||||||
db: &State<SqlitePool>,
|
|
||||||
data: Form<LogToAdd>,
|
|
||||||
) -> Flash<Redirect> {
|
|
||||||
match Logbook::create(
|
match Logbook::create(
|
||||||
db,
|
db,
|
||||||
data.into_inner()
|
data.into_inner()
|
||||||
@ -140,7 +141,6 @@ async fn create_kiosk(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[post("/<logbook_id>", data = "<data>")]
|
#[post("/<logbook_id>", data = "<data>")]
|
||||||
async fn home_kiosk(
|
async fn home_kiosk(
|
||||||
db: &State<SqlitePool>,
|
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"),
|
Ok(_) => Flash::success(Redirect::to("/log"), "Successfully updated log"),
|
||||||
Err(_) => Flash::error(
|
Err(_) => Flash::error(
|
||||||
Redirect::to("/log"),
|
Redirect::to("/log"),
|
||||||
@ -164,8 +173,7 @@ async fn home_kiosk(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[post("/<logbook_id>", data = "<data>", rank = 2)]
|
||||||
#[post("/<logbook_id>", data = "<data>", rank=2)]
|
|
||||||
async fn home(
|
async fn home(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<LogToFinalize>,
|
data: Form<LogToFinalize>,
|
||||||
@ -190,7 +198,15 @@ async fn home(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
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)]
|
#[cfg(test)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user