only have a single user with details struct
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m45s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-05-06 12:17:03 +02:00
parent fcb4d65d32
commit 45b51f4698
14 changed files with 49 additions and 85 deletions

View File

@ -24,9 +24,7 @@ use crate::model::{
LogbookUpdateError,
},
logtype::LogType,
user::{
AdminUser, DonauLinzUser, User, UserWithRolesAndNotificationCount, UserWithWaterStatus,
},
user::{AdminUser, DonauLinzUser, User, UserWithDetails},
};
pub struct KioskCookie(String);
@ -51,22 +49,22 @@ async fn index(
) -> Template {
let boats = Boat::for_user(db, &user).await;
let mut coxes: Vec<UserWithWaterStatus> = futures::future::join_all(
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
User::cox(db)
.await
.into_iter()
.map(|user| UserWithWaterStatus::from_user(user, db)),
.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<UserWithWaterStatus> = futures::future::join_all(
let mut users: Vec<UserWithDetails> = futures::future::join_all(
User::all(db)
.await
.into_iter()
.map(|user| UserWithWaterStatus::from_user(user, db)),
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
users.retain(|u| {
@ -93,7 +91,7 @@ async fn index(
context.insert("logtypes", &logtypes);
context.insert(
"loggedin_user",
&UserWithRolesAndNotificationCount::from_user(user.into(), db).await,
&UserWithDetails::from_user(user.into(), db).await,
);
context.insert("on_water", &on_water);
context.insert("distances", &distances);
@ -107,7 +105,7 @@ async fn show(db: &State<SqlitePool>, user: DonauLinzUser) -> Template {
Template::render(
"log.completed",
context!(logs, loggedin_user: &UserWithRolesAndNotificationCount::from_user(user.into(), db).await),
context!(logs, loggedin_user: &UserWithDetails::from_user(user.into(), db).await),
)
}
@ -117,7 +115,7 @@ async fn show_for_year(db: &State<SqlitePool>, user: AdminUser, year: i32) -> Te
Template::render(
"log.completed",
context!(logs, loggedin_user: &UserWithRolesAndNotificationCount::from_user(user.user, db).await),
context!(logs, loggedin_user: &UserWithDetails::from_user(user.user, db).await),
)
}
@ -153,11 +151,11 @@ async fn kiosk(
_kiosk: KioskCookie,
) -> Template {
let boats = Boat::all(db).await;
let mut coxes: Vec<UserWithWaterStatus> = futures::future::join_all(
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
User::cox(db)
.await
.into_iter()
.map(|user| UserWithWaterStatus::from_user(user, db)),
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;
@ -165,11 +163,11 @@ async fn kiosk(
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
});
let mut users: Vec<UserWithWaterStatus> = futures::future::join_all(
let mut users: Vec<UserWithDetails> = futures::future::join_all(
User::all(db)
.await
.into_iter()
.map(|user| UserWithWaterStatus::from_user(user, db)),
.map(|user| UserWithDetails::from_user(user, db)),
)
.await;