7 Commits

Author SHA1 Message Date
7be9339645 Merge pull request 'merge functionality of kiosk + logged in -> allow kiosk to have fördernde people as rower in logbook' (#1097) from kiosk-allow-foerdernde into main
Some checks failed
CI/CD Pipeline / test (push) Failing after 28m7s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #1097
2025-07-13 19:52:33 +02:00
837d0febdf merge functionality of kiosk + logged in -> allow kiosk to have fördernde people as rower in logbook
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-07-13 19:49:46 +02:00
51c7cf28f8 Merge pull request 'foerderne user can do trips on the water' (#1094) from foerderne-user-can-do-trips into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 27m36s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 35m11s
Reviewed-on: #1094
2025-07-13 09:26:57 +02:00
80eca1a3b2 foerderne user can do trips on the water
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-07-13 09:22:47 +02:00
d1341006f7 Merge pull request 'allow to change from 'bootsfuehrer' to 'cox'' (#1090) from bootsman-to-cox into main
Some checks failed
CI/CD Pipeline / test (push) Failing after 32m16s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #1090
2025-07-03 11:03:50 +02:00
a534568a39 allow to change from 'bootsfuehrer' to 'cox'
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2025-07-03 11:02:59 +02:00
b4c04cbdd8 Merge pull request 'updates-meeting' (#1085) from updates-meeting into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 20m54s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #1085
2025-06-17 22:53:40 +02:00
4 changed files with 75 additions and 81 deletions

View File

@ -342,12 +342,33 @@ impl User {
None,
)
.await;
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Schiffsführer mehr)"))
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Bootsführer mehr)"))
.user(self)
.save(db)
.await;
}
}
(old, new) if old == Some(bootsfuehrer.clone()) && new == Some(cox.clone()) => {
self.remove_role(db, updated_by, &bootsfuehrer).await?;
self.add_role(db, updated_by, &cox).await?;
Notification::create_for_role(
db,
&member,
&format!(
"Lieber Vorstand, {self} ist ab sofort kein Bootsführer:in mehr, sondern 'nur' mehr eine Steuerperson."
),
"Bootsführer--",
None,
None,
)
.await;
ActivityBuilder::new(&format!(
"{updated_by} hat {self} zur Steuerperson gemacht (kein Bootsführer mehr)"
))
.user(self)
.save(db)
.await;
}
(old, new) => return Err(format!("Not allowed to change from {old:?} to {new:?}")),
};
@ -508,6 +529,13 @@ impl User {
}
pub(crate) async fn remove_membership_pdf(&self, db: &SqlitePool, updated_by: &ManageUserUser) {
ActivityBuilder::new(&format!(
"{updated_by} hat die Beitrittserklärung vom Beutzer gelöscht."
))
.user(self)
.save(db)
.await;
sqlx::query!(
"UPDATE user SET membership_pdf = null where id = ?",
self.id

View File

@ -102,6 +102,13 @@ impl UserWithDetails {
user,
}
}
pub fn allowed_to_row(&self) -> bool {
self.roles.contains(&"Donau Linz".into())
|| self.roles.contains(&"Förderndes Mitglied".into())
|| self.roles.contains(&"scheckbuch".into())
|| self.user.name == "Externe Steuerperson"
}
}
#[derive(Debug)]

View File

@ -40,7 +40,7 @@ async fn index(
let allowed_to_edit = AllowedToUpdateBoathouse::new(db, &admin.user)
.await
.is_some();
context.insert("allowed_to_edit", &boathouse);
context.insert("allowed_to_edit", &allowed_to_edit);
context.insert(
"loggedin_user",

View File

@ -47,12 +47,44 @@ impl<'r> FromRequest<'r> for KioskCookie {
}
#[get("/", rank = 2)]
async fn index(
async fn index_loggedin(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
user: DonauLinzUser,
) -> Template {
let mut context = Context::new();
let boats = Boat::for_user(db, &user).await;
context.insert("boats", &boats);
context.insert(
"loggedin_user",
&UserWithDetails::from_user(user.into_inner(), db).await,
);
index(db, flash, context).await
}
#[get("/")]
async fn index_kiosk(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
_kiosk: KioskCookie,
) -> Template {
let mut context = Context::new();
let boats = Boat::all(db).await;
context.insert("boats", &boats);
context.insert("show_kiosk_header", &true);
index(db, flash, context).await
}
async fn index(db: &SqlitePool, flash: Option<FlashMessage<'_>>, mut context: Context) -> Template {
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
User::cox(db)
@ -61,9 +93,7 @@ async fn index(
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
coxes.retain(|u| {
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
});
coxes.retain(|u| u.roles.contains(&"Donau Linz".into()));
let mut users: Vec<UserWithDetails> = futures::future::join_all(
User::all(db)
@ -72,23 +102,13 @@ async fn index(
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
users.retain(|u| {
u.roles.contains(&"Donau Linz".into())
|| u.roles.contains(&"scheckbuch".into())
|| u.user.name == "Externe Steuerperson"
});
users.retain(|u| u.allowed_to_row());
let logtypes = LogType::all(db).await;
let distances = Distance::all(db).await;
let on_water = Logbook::on_water(db).await;
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
context.insert("boats", &boats);
context.insert("planned_trips", &Trip::get_for_today(db).await);
context.insert(
"reservations",
@ -97,14 +117,10 @@ async fn index(
context.insert("coxes", &coxes);
context.insert("users", &users);
context.insert("logtypes", &logtypes);
context.insert(
"loggedin_user",
&UserWithDetails::from_user(user.into_inner(), db).await,
);
context.insert("on_water", &on_water);
context.insert("distances", &distances);
Template::render("log", context.into_json())
Template::render("kiosk", context.into_json())
}
#[get("/show", rank = 3)]
@ -179,63 +195,6 @@ async fn new_kiosk(
Redirect::to("/log")
}
#[get("/")]
async fn kiosk(
db: &State<SqlitePool>,
flash: Option<FlashMessage<'_>>,
_kiosk: KioskCookie,
) -> Template {
let boats = Boat::all(db).await;
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
User::cox(db)
.await
.into_iter()
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
coxes.retain(|u| {
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
});
let mut users: Vec<UserWithDetails> = futures::future::join_all(
User::all(db)
.await
.into_iter()
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
users.retain(|u| {
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
});
let logtypes = LogType::all(db).await;
let distances = Distance::all(db).await;
let on_water = Logbook::on_water(db).await;
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}
context.insert("planned_trips", &Trip::get_for_today(db).await);
context.insert("boats", &boats);
context.insert(
"reservations",
&BoatReservation::all_future_with_groups(db).await,
);
context.insert("coxes", &coxes);
context.insert("users", &users);
context.insert("logtypes", &logtypes);
context.insert("on_water", &on_water);
context.insert("distances", &distances);
context.insert("show_kiosk_header", &true);
Template::render("kiosk", context.into_json())
}
async fn create_logbook(
db: &SqlitePool,
data: Form<LogToAdd>,
@ -568,11 +527,11 @@ async fn delete_kiosk(
pub fn routes() -> Vec<Route> {
routes![
index,
index_loggedin,
index_kiosk,
create,
create_kiosk,
home,
kiosk,
home_kiosk,
new_kiosk,
show,