Compare commits
No commits in common. "c98f33e138a0f86289bcbd8946cf90afb189239f" and "1503544a73c6b9596612a13cc48a04166ae72a78" have entirely different histories.
c98f33e138
...
1503544a73
@ -181,11 +181,13 @@ AND date('now') BETWEEN start_date AND end_date;",
|
|||||||
damage = BoatDamage::Locked;
|
damage = BoatDamage::Locked;
|
||||||
}
|
}
|
||||||
let cat = if boat.external {
|
let cat = if boat.external {
|
||||||
"Vereinsfremde Boote".to_string()
|
format!("Vereinsfremde Boote")
|
||||||
} else if boat.default_shipmaster_only_steering {
|
} else {
|
||||||
|
if boat.default_shipmaster_only_steering {
|
||||||
format!("{}+", boat.amount_seats - 1)
|
format!("{}+", boat.amount_seats - 1)
|
||||||
} else {
|
} else {
|
||||||
format!("{}x", boat.amount_seats)
|
format!("{}x", boat.amount_seats)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
res.push(BoatWithDetails {
|
res.push(BoatWithDetails {
|
||||||
|
@ -114,7 +114,7 @@ WHERE end_date >= CURRENT_DATE ORDER BY end_date
|
|||||||
|
|
||||||
grouped_reservations
|
grouped_reservations
|
||||||
.entry(key)
|
.entry(key)
|
||||||
.or_default()
|
.or_insert_with(Vec::new)
|
||||||
.push(reservation);
|
.push(reservation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,11 +303,11 @@ ORDER BY departure DESC
|
|||||||
return Err(LogbookCreateError::BoatNotFound);
|
return Err(LogbookCreateError::BoatNotFound);
|
||||||
};
|
};
|
||||||
|
|
||||||
if log.shipmaster_only_steering != boat.default_shipmaster_only_steering
|
if log.shipmaster_only_steering != boat.default_shipmaster_only_steering {
|
||||||
&& !boat.convert_handoperated_possible
|
if !boat.convert_handoperated_possible {
|
||||||
{
|
|
||||||
return Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat);
|
return Err(LogbookCreateError::CantChangeHandoperatableStatusForThisBoat);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if boat.amount_seats == 1 && log.rowers.is_empty() {
|
if boat.amount_seats == 1 && log.rowers.is_empty() {
|
||||||
log.rowers = vec![created_by_user.id];
|
log.rowers = vec![created_by_user.id];
|
||||||
|
@ -26,7 +26,7 @@ const REGULAR: i32 = 22000;
|
|||||||
const UNTERSTUETZEND: i32 = 2500;
|
const UNTERSTUETZEND: i32 = 2500;
|
||||||
const FOERDERND: i32 = 8500;
|
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 struct User {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub name: String,
|
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)]
|
#[derive(Debug)]
|
||||||
pub enum LoginError {
|
pub enum LoginError {
|
||||||
InvalidAuthenticationCombo,
|
InvalidAuthenticationCombo,
|
||||||
|
@ -3,10 +3,30 @@ use crate::model::{
|
|||||||
user::{SchnupperBetreuerUser, User, UserWithRolesAndNotificationCount},
|
user::{SchnupperBetreuerUser, User, UserWithRolesAndNotificationCount},
|
||||||
};
|
};
|
||||||
use futures::future::join_all;
|
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 rocket_dyn_templates::{tera::Context, Template};
|
||||||
use sqlx::SqlitePool;
|
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")]
|
#[get("/schnupper")]
|
||||||
async fn index(
|
async fn index(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
|
@ -166,7 +166,7 @@ async fn update(
|
|||||||
if user.id != reservation.user_id_applicant && !user.has_role(db, "admin").await {
|
if user.id != reservation.user_id_applicant && !user.has_role(db, "admin").await {
|
||||||
return Flash::error(
|
return Flash::error(
|
||||||
Redirect::to("/boatreservation"),
|
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)."),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ async fn create_kiosk(
|
|||||||
} else if let Some(shipmaster) = data.shipmaster {
|
} else if let Some(shipmaster) = data.shipmaster {
|
||||||
User::find_by_id(db, shipmaster as i32).await.unwrap()
|
User::find_by_id(db, shipmaster as i32).await.unwrap()
|
||||||
} else {
|
} else {
|
||||||
let Some(rower) = data.rowers.first() else {
|
let Some(rower) = data.rowers.get(0) else {
|
||||||
return Flash::error(
|
return Flash::error(
|
||||||
Redirect::to("/log"),
|
Redirect::to("/log"),
|
||||||
"Ausfahrt ohne Benutzer kann nicht angelegt werden.",
|
"Ausfahrt ohne Benutzer kann nicht angelegt werden.",
|
||||||
|
@ -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.")
|
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]
|
#[rocket::async_trait]
|
||||||
impl Fairing for Usage {
|
impl Fairing for Usage {
|
||||||
@ -194,7 +196,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
|
|||||||
.register("/", catchers![unauthorized_error, forbidden_error])
|
.register("/", catchers![unauthorized_error, forbidden_error])
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
.attach(AdHoc::config::<Config>())
|
.attach(AdHoc::config::<Config>())
|
||||||
.attach(Usage {})
|
.attach(Usage { data: Vec::new() })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user