show waterlevel for the next days #466
@ -181,13 +181,11 @@ 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 {
|
||||||
format!("Vereinsfremde Boote")
|
"Vereinsfremde Boote".to_string()
|
||||||
|
} else if boat.default_shipmaster_only_steering {
|
||||||
|
format!("{}+", boat.amount_seats - 1)
|
||||||
} else {
|
} else {
|
||||||
if boat.default_shipmaster_only_steering {
|
format!("{}x", boat.amount_seats)
|
||||||
format!("{}+", boat.amount_seats - 1)
|
|
||||||
} else {
|
|
||||||
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_insert_with(Vec::new)
|
.or_default()
|
||||||
.push(reservation);
|
.push(reservation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,10 +303,10 @@ 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
|
||||||
if !boat.convert_handoperated_possible {
|
&& !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() {
|
||||||
|
@ -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)]
|
#[derive(FromRow, Serialize, Deserialize, Clone, Debug, Eq, Hash, PartialEq)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub name: String,
|
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)]
|
#[derive(Debug)]
|
||||||
pub enum LoginError {
|
pub enum LoginError {
|
||||||
InvalidAuthenticationCombo,
|
InvalidAuthenticationCombo,
|
||||||
|
@ -3,30 +3,10 @@ use crate::model::{
|
|||||||
user::{SchnupperBetreuerUser, User, UserWithRolesAndNotificationCount},
|
user::{SchnupperBetreuerUser, User, UserWithRolesAndNotificationCount},
|
||||||
};
|
};
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use rocket::{
|
use rocket::{get, request::FlashMessage, routes, Route, State};
|
||||||
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"),
|
||||||
format!("Not allowed to update reservation (only admins + creator do so)."),
|
"Not allowed to update reservation (only admins + creator do so).".to_string(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.get(0) else {
|
let Some(rower) = data.rowers.first() 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,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.")
|
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 {
|
||||||
@ -196,7 +194,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 { data: Vec::new() })
|
.attach(Usage {})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user