From db3158d4e78979eb344fb5bbb715c3625ae7fb0e Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 7 Apr 2024 23:17:06 +0200 Subject: [PATCH] only allow people with 'donau linz' role to be in logbook --- src/tera/log.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tera/log.rs b/src/tera/log.rs index 686867d..1fe6b15 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -1,5 +1,6 @@ use std::net::IpAddr; +use futures::{stream, StreamExt}; use rocket::{ form::Form, get, @@ -49,20 +50,24 @@ async fn index( ) -> Template { let boats = Boat::for_user(db, &user).await; - let coxes: Vec = futures::future::join_all( + let mut coxes: Vec = futures::future::join_all( User::cox(db) .await .into_iter() .map(|user| UserWithWaterStatus::from_user(user, db)), ) .await; - let users: Vec = futures::future::join_all( + coxes.retain(|u| u.roles.contains(&"Donau Linz".into())); + + let mut users: Vec = futures::future::join_all( User::all(db) .await .into_iter() .map(|user| UserWithWaterStatus::from_user(user, db)), ) .await; + users.retain(|u| u.roles.contains(&"Donau Linz".into())); + let logtypes = LogType::all(db).await; let distances = Logbook::distances(db).await;