better layout
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
2024-05-16 22:35:26 +02:00
parent f034f80794
commit 0eac1a66f9
4 changed files with 77 additions and 85 deletions

View File

@ -21,9 +21,10 @@ use sqlx::SqlitePool;
use tera::Context;
use crate::model::{
logbook::Logbook,
notification::Notification,
role::Role,
user::{User, UserWithDetails},
user::{User, UserWithDetails, SCHECKBUCH},
};
pub(crate) mod admin;
@ -52,8 +53,15 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
context.insert("flash", &msg.into_inner());
}
if user.has_role(db, "scheckbuch").await {
let last_trips = Logbook::completed_with_user(db, &user).await;
context.insert("last_trips", &last_trips);
}
context.insert("notifications", &Notification::for_user(db, &user).await);
context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await);
context.insert("costs_scheckbuch", &SCHECKBUCH);
Template::render("index", context.into_json())
}

View File

@ -32,11 +32,6 @@ async fn index(
context.insert("trip_types", &triptypes);
}
if user.has_role(db, "scheckbuch").await {
let last_trips = Logbook::completed_with_user(db, &user).await;
context.insert("last_trips", &last_trips);
}
let days = user.get_days(db).await;
if let Some(msg) = flash {
@ -46,7 +41,6 @@ async fn index(
context.insert("fee", &user.fee(db).await);
context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await);
context.insert("days", &days);
context.insert("costs_scheckbuch", &SCHECKBUCH);
Template::render("planned", context.into_json())
}