allow-scheckbuch-to-be-entered #476

Merged
philipp merged 4 commits from allow-scheckbuch-to-be-entered into staging 2024-05-01 19:37:11 +02:00
8 changed files with 15 additions and 45 deletions
Showing only changes of commit b70929c5ce - Show all commits

View File

@ -181,13 +181,11 @@ AND date('now') BETWEEN start_date AND end_date;",
damage = BoatDamage::Locked;
}
let cat = if boat.external {
format!("Vereinsfremde Boote")
} else {
if boat.default_shipmaster_only_steering {
"Vereinsfremde Boote".to_string()
} else if boat.default_shipmaster_only_steering {
format!("{}+", boat.amount_seats - 1)
} else {
format!("{}x", boat.amount_seats)
}
};
res.push(BoatWithDetails {

View File

@ -114,7 +114,7 @@ WHERE end_date >= CURRENT_DATE ORDER BY end_date
grouped_reservations
.entry(key)
.or_insert_with(Vec::new)
.or_default()
.push(reservation);
}

View File

@ -303,11 +303,11 @@ ORDER BY departure DESC
return Err(LogbookCreateError::BoatNotFound);
};
if log.shipmaster_only_steering != boat.default_shipmaster_only_steering {
if !boat.convert_handoperated_possible {
if log.shipmaster_only_steering != boat.default_shipmaster_only_steering
&& !boat.convert_handoperated_possible
{
return Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat);
}
}
if boat.amount_seats == 1 && log.rowers.is_empty() {
log.rowers = vec![created_by_user.id];

View File

@ -26,7 +26,7 @@ const REGULAR: i32 = 22000;
const UNTERSTUETZEND: i32 = 2500;
const FOERDERND: i32 = 8500;
#[derive(FromRow, Serialize, Deserialize, Clone, Debug, Eq, Hash)]
#[derive(FromRow, Serialize, Deserialize, Clone, Debug, Eq, Hash, PartialEq)]
pub struct User {
pub id: i64,
pub name: String,
@ -82,12 +82,6 @@ impl UserWithWaterStatus {
}
}
impl PartialEq for User {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
#[derive(Debug)]
pub enum LoginError {
InvalidAuthenticationCombo,

View File

@ -3,30 +3,10 @@ use crate::model::{
user::{SchnupperBetreuerUser, User, UserWithRolesAndNotificationCount},
};
use futures::future::join_all;
use rocket::{
get,
http::Status,
request::{FlashMessage, FromRequest, Outcome},
routes, Request, Route, State,
};
use rocket::{get, request::FlashMessage, routes, Route, State};
use rocket_dyn_templates::{tera::Context, Template};
use sqlx::SqlitePool;
// Custom request guard to extract the Referer header
struct Referer(String);
#[rocket::async_trait]
impl<'r> FromRequest<'r> for Referer {
type Error = ();
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> {
match request.headers().get_one("Referer") {
Some(referer) => Outcome::Success(Referer(referer.to_string())),
None => Outcome::Error((Status::BadRequest, ())),
}
}
}
#[get("/schnupper")]
async fn index(
db: &State<SqlitePool>,

View File

@ -166,7 +166,7 @@ async fn update(
if user.id != reservation.user_id_applicant && !user.has_role(db, "admin").await {
return Flash::error(
Redirect::to("/boatreservation"),
format!("Not allowed to update reservation (only admins + creator do so)."),
"Not allowed to update reservation (only admins + creator do so).".to_string(),
);
}

View File

@ -250,7 +250,7 @@ async fn create_kiosk(
} else if let Some(shipmaster) = data.shipmaster {
User::find_by_id(db, shipmaster as i32).await.unwrap()
} else {
let Some(rower) = data.rowers.get(0) else {
let Some(rower) = data.rowers.first() else {
return Flash::error(
Redirect::to("/log"),
"Ausfahrt ohne Benutzer kann nicht angelegt werden.",

View File

@ -109,9 +109,7 @@ fn forbidden_error() -> Flash<Redirect> {
Flash::error(Redirect::to("/"), "Keine Berechtigung für diese Aktion. Wenn du der Meinung bist, dass du das machen darfst, melde dich bitte bei it@rudernlinz.at.")
}
struct Usage {
data: Vec<String>,
}
struct Usage {}
#[rocket::async_trait]
impl Fairing for Usage {
@ -196,7 +194,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
.register("/", catchers![unauthorized_error, forbidden_error])
.attach(Template::fairing())
.attach(AdHoc::config::<Config>())
.attach(Usage { data: Vec::new() })
.attach(Usage {})
}
#[cfg(test)]