Compare commits

..

No commits in common. "b70929c5cec10ab606cf31a89149700e1cf8bc83" and "a75ba765dfab87f4f0bb1814eb72f66928175118" have entirely different histories.

8 changed files with 45 additions and 15 deletions

View File

@ -181,11 +181,13 @@ AND date('now') BETWEEN start_date AND end_date;",
damage = BoatDamage::Locked;
}
let cat = if boat.external {
"Vereinsfremde Boote".to_string()
} else if boat.default_shipmaster_only_steering {
format!("{}+", boat.amount_seats - 1)
format!("Vereinsfremde Boote")
} else {
format!("{}x", boat.amount_seats)
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_default()
.or_insert_with(Vec::new)
.push(reservation);
}

View File

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

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, PartialEq)]
#[derive(FromRow, Serialize, Deserialize, Clone, Debug, Eq, Hash)]
pub struct User {
pub id: i64,
pub name: String,
@ -82,6 +82,12 @@ 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,10 +3,30 @@ use crate::model::{
user::{SchnupperBetreuerUser, User, UserWithRolesAndNotificationCount},
};
use futures::future::join_all;
use rocket::{get, request::FlashMessage, routes, Route, State};
use rocket::{
get,
http::Status,
request::{FlashMessage, FromRequest, Outcome},
routes, Request, 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"),
"Not allowed to update reservation (only admins + creator do so).".to_string(),
format!("Not allowed to update reservation (only admins + creator do so)."),
);
}

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.first() else {
let Some(rower) = data.rowers.get(0) else {
return Flash::error(
Redirect::to("/log"),
"Ausfahrt ohne Benutzer kann nicht angelegt werden.",

View File

@ -109,7 +109,9 @@ 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 {}
struct Usage {
data: Vec<String>,
}
#[rocket::async_trait]
impl Fairing for Usage {
@ -194,7 +196,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
.register("/", catchers![unauthorized_error, forbidden_error])
.attach(Template::fairing())
.attach(AdHoc::config::<Config>())
.attach(Usage {})
.attach(Usage { data: Vec::new() })
}
#[cfg(test)]