make scheckbuch user behave as previously, but in own file

This commit is contained in:
2025-04-29 21:00:50 +02:00
parent 876451fc02
commit 7604678d4a
8 changed files with 42 additions and 32 deletions

View File

@ -27,6 +27,7 @@ use super::{
Day,
};
use crate::{tera::admin::user::UserEditForm, AMOUNT_DAYS_TO_SHOW_TRIPS_AHEAD};
use scheckbuch::ScheckbuchUser;
mod fee;
mod scheckbuch;
@ -112,6 +113,8 @@ impl User {
.await?;
} else if self.has_role(db, "schnupperant").await {
self.send_welcome_mail_schnupper(db, mail, smtp_pw).await?;
} else if let Some(scheckbuch) = ScheckbuchUser::new(db, &self).await {
scheckbuch.notify(db, mail, smtp_pw).await?;
} else {
return Err(format!(
"Could not send welcome mail, because user {} is not in Donau Linz or scheckbuch or schnupperant group",
@ -259,7 +262,7 @@ ASKÖ Ruderverein Donau Linz", self.name),
}
pub async fn allowed_to_update_always_show_trip(&self, db: &SqlitePool) -> bool {
AllowedToUpdateTripToAlwaysBeShownUser::new(db, self.clone())
AllowedToUpdateTripToAlwaysBeShownUser::new(db, &self)
.await
.is_some()
}
@ -989,9 +992,9 @@ macro_rules! special_user {
}
impl $name {
pub async fn new(db: &SqlitePool, user: User) -> Option<Self> {
pub async fn new(db: &SqlitePool, user: &User) -> Option<Self> {
if special_user!(@check_roles user, db, $($role)*) {
Some($name { user })
Some($name { user: user.clone() })
} else {
None
}