Only show Vereinsmitglied-block for members
All checks were successful
CI/CD Pipeline / test (push) Successful in 13m57s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
Philipp Hofer 2025-04-30 13:55:52 +02:00
parent d2914f9287
commit 19887e133d
3 changed files with 10 additions and 4 deletions

View File

@ -933,7 +933,7 @@ impl<'r> FromRequest<'r> for User {
#[macro_export] #[macro_export]
macro_rules! special_user { macro_rules! special_user {
($name:ident, $($role:tt)*) => { ($name:ident, $($role:tt)*) => {
#[derive(Debug)] #[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct $name { pub struct $name {
pub(crate) user: User, pub(crate) user: User,
} }
@ -1015,6 +1015,7 @@ special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
special_user!(ManageUserUser, +"admin", +"schriftfuehrer"); special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
special_user!(AllowedToSendFeeReminderUser, +"admin", +"schriftfuehrer", +"kassier"); special_user!(AllowedToSendFeeReminderUser, +"admin", +"schriftfuehrer", +"kassier");
special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin"); special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin");
special_user!(ClubMember, +"Donau Linz");
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)] #[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
pub struct UserWithRolesAndMembershipPdf { pub struct UserWithRolesAndMembershipPdf {

View File

@ -7,8 +7,8 @@ use crate::{
logbook::Logbook, logbook::Logbook,
role::Role, role::Role,
user::{ user::{
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, User, UserWithDetails, AdminUser, AllowedToEditPaymentStatusUser, ClubMember, ManageUserUser, User,
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser, UserWithDetails, UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
}, },
}, },
tera::Config, tera::Config,
@ -121,10 +121,12 @@ async fn view(
) -> Result<Template, Flash<Redirect>> { ) -> Result<Template, Flash<Redirect>> {
let Some(user) = User::find_by_id(db, user).await else { let Some(user) = User::find_by_id(db, user).await else {
return Err(Flash::error( return Err(Flash::error(
Redirect::to("/admin/usert"), Redirect::to("/admin/user"),
format!("User mit ID {} gibts ned", user), format!("User mit ID {} gibts ned", user),
)); ));
}; };
let clubmember = ClubMember::new(db, &user).await;
let user = UserWithRolesAndMembershipPdf::from_user(db, user).await; let user = UserWithRolesAndMembershipPdf::from_user(db, user).await;
let admin: User = admin.into_inner(); let admin: User = admin.into_inner();
@ -139,6 +141,7 @@ async fn view(
} }
context.insert("allowed_to_edit", &allowed_to_edit); context.insert("allowed_to_edit", &allowed_to_edit);
context.insert("user", &user); context.insert("user", &user);
context.insert("clubmember", &clubmember);
context.insert("roles", &roles); context.insert("roles", &roles);
context.insert("families", &families); context.insert("families", &families);
context.insert( context.insert(

View File

@ -90,6 +90,7 @@
</div> </div>
</div> </div>
</div> </div>
{% if clubmember %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert"> role="alert">
<h2 class="h2">Vereinsmitglied</h2> <h2 class="h2">Vereinsmitglied</h2>
@ -180,6 +181,7 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% endif %}
<div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5" <div class="bg-white dark:bg-primary-900 text-black dark:text-white rounded-md block shadow mt-5"
role="alert"> role="alert">
<h2 class="h2">Aktivität von und mit {{ user.name }}</h2> <h2 class="h2">Aktivität von und mit {{ user.name }}</h2>