forked from Ruderverein-Donau-Linz/rowt
make scheckbuch user behave as previously, but in own file
This commit is contained in:
@ -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
|
||||
}
|
||||
|
@ -30,16 +30,23 @@ impl ScheckbuchUser {
|
||||
user.add_role(db, &scheckbuch).await.unwrap();
|
||||
|
||||
// TODO: remove all other `membership_type` roles
|
||||
let new_user = Self::new(db, &user).await.unwrap();
|
||||
|
||||
let new_user = Self::new(db, user).await.unwrap();
|
||||
new_user.notify(db, mail, smtp_pw).await
|
||||
}
|
||||
|
||||
new_user
|
||||
.send_welcome_mail_to_user(db, mail, smtp_pw)
|
||||
.await?;
|
||||
new_user.notify_coxes_about_new_scheckbuch(db).await;
|
||||
pub(crate) async fn notify(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
mail: &str,
|
||||
smtp_pw: &str,
|
||||
) -> Result<(), String> {
|
||||
self.send_welcome_mail_to_user(db, mail, smtp_pw).await?;
|
||||
self.notify_coxes_about_new_scheckbuch(db).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn send_welcome_mail_to_user(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
|
Reference in New Issue
Block a user