clean code with clippy
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions

This commit is contained in:
2024-05-22 00:13:23 +02:00
parent 6b911f242a
commit 40f97f18a9
11 changed files with 151 additions and 124 deletions

View File

@ -8,7 +8,7 @@ use serde::Serialize;
use sqlx::SqlitePool;
use crate::model::{
planned_event::PlannedEvent,
planned_event::{self, PlannedEvent},
tripdetails::{TripDetails, TripDetailsToAdd},
user::PlannedEventUser,
};
@ -57,19 +57,17 @@ async fn update(
data: Form<UpdatePlannedEventForm<'_>>,
_admin: PlannedEventUser,
) -> Flash<Redirect> {
let update = planned_event::EventUpdate {
name: data.name,
planned_amount_cox: data.planned_amount_cox,
max_people: data.max_people,
notes: data.notes,
always_show: data.always_show,
is_locked: data.is_locked,
};
match PlannedEvent::find_by_id(db, data.id).await {
Some(planned_event) => {
planned_event
.update(
db,
data.name,
data.planned_amount_cox,
data.max_people,
data.notes,
data.always_show,
data.is_locked,
)
.await;
planned_event.update(db, &update).await;
Flash::success(Redirect::to("/planned"), "Event erfolgreich bearbeitet")
}
None => Flash::error(Redirect::to("/planned"), "Planned event id not found"),

View File

@ -39,7 +39,6 @@ struct LoginForm<'r> {
password: &'r str,
}
#[derive(Debug)]
pub struct UserAgent(String);
#[rocket::async_trait]
@ -83,8 +82,8 @@ async fn login(
Log::create(
db,
format!(
"Succ login of {} with this useragent: {:?}",
login.name, agent
"Succ login of {} with this useragent: {}",
login.name, agent.0
),
)
.await;

View File

@ -9,7 +9,7 @@ use sqlx::SqlitePool;
use crate::model::{
log::Log,
planned_event::PlannedEvent,
trip::{CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
trip::{self, CoxHelpError, Trip, TripDeleteError, TripHelpDeleteError, TripUpdateError},
tripdetails::{TripDetails, TripDetailsToAdd},
user::CoxUser,
};
@ -54,18 +54,16 @@ async fn update(
cox: CoxUser,
) -> Flash<Redirect> {
if let Some(trip) = Trip::find_by_id(db, trip_id).await {
match Trip::update_own(
db,
&cox,
&trip,
data.max_people,
data.notes,
data.trip_type,
data.always_show,
data.is_locked,
)
.await
{
let update = trip::TripUpdate {
cox: &cox,
trip: &trip,
max_people: data.max_people,
notes: data.notes,
trip_type: data.trip_type,
always_show: data.always_show,
is_locked: data.is_locked,
};
match Trip::update_own(db, &update).await {
Ok(_) => Flash::success(
Redirect::to("/planned"),
"Ausfahrt erfolgreich aktualisiert.",

View File

@ -27,7 +27,7 @@ use crate::model::{
user::{AdminUser, DonauLinzUser, User, UserWithDetails},
};
pub struct KioskCookie(String);
pub struct KioskCookie(());
#[rocket::async_trait]
impl<'r> FromRequest<'r> for KioskCookie {
@ -35,7 +35,7 @@ impl<'r> FromRequest<'r> for KioskCookie {
async fn from_request(request: &'r Request<'_>) -> request::Outcome<KioskCookie, Self::Error> {
match request.cookies().get_private("kiosk") {
Some(cookie) => request::Outcome::Success(KioskCookie(cookie.value().to_string())),
Some(_) => request::Outcome::Success(KioskCookie(())),
None => request::Outcome::Forward(rocket::http::Status::SeeOther),
}
}