only allow people with 'donau linz' role to be in logbook
All checks were successful
CI/CD Pipeline / test (push) Successful in 11m24s
CI/CD Pipeline / deploy-staging (push) Successful in 5m24s
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
philipp 2024-04-07 23:17:06 +02:00
parent 7cbfafa5c5
commit db3158d4e7

View File

@ -1,5 +1,6 @@
use std::net::IpAddr; use std::net::IpAddr;
use futures::{stream, StreamExt};
use rocket::{ use rocket::{
form::Form, form::Form,
get, get,
@ -49,20 +50,24 @@ async fn index(
) -> Template { ) -> Template {
let boats = Boat::for_user(db, &user).await; let boats = Boat::for_user(db, &user).await;
let coxes: Vec<UserWithWaterStatus> = futures::future::join_all( let mut coxes: Vec<UserWithWaterStatus> = futures::future::join_all(
User::cox(db) User::cox(db)
.await .await
.into_iter() .into_iter()
.map(|user| UserWithWaterStatus::from_user(user, db)), .map(|user| UserWithWaterStatus::from_user(user, db)),
) )
.await; .await;
let users: Vec<UserWithWaterStatus> = futures::future::join_all( coxes.retain(|u| u.roles.contains(&"Donau Linz".into()));
let mut users: Vec<UserWithWaterStatus> = futures::future::join_all(
User::all(db) User::all(db)
.await .await
.into_iter() .into_iter()
.map(|user| UserWithWaterStatus::from_user(user, db)), .map(|user| UserWithWaterStatus::from_user(user, db)),
) )
.await; .await;
users.retain(|u| u.roles.contains(&"Donau Linz".into()));
let logtypes = LogType::all(db).await; let logtypes = LogType::all(db).await;
let distances = Logbook::distances(db).await; let distances = Logbook::distances(db).await;