inform board if more trips than allowed
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
philipp 2024-09-12 08:35:10 +02:00
parent 1225aeac94
commit b429998775

View File

@ -257,8 +257,6 @@ ASKÖ Ruderverein Donau Linz", self.name, SCHECKBUCH/100),
mail: &str, mail: &str,
smtp_pw: &str, smtp_pw: &str,
) -> Result<(), String> { ) -> Result<(), String> {
// 2 things to do:
// 1. Send mail to user
Mail::send_single_tx( Mail::send_single_tx(
db, db,
mail, mail,
@ -279,20 +277,6 @@ ASKÖ Ruderverein Donau Linz", self.name),
smtp_pw, smtp_pw,
).await?; ).await?;
// 2. Notify all coxes
let coxes = Role::find_by_name_tx(db, "cox").await.unwrap();
Notification::create_for_role_tx(
db,
&coxes,
&format!(
"Liebe Steuerberechtigte, {} hat alle Ausfahrten des Scheckbuchs absolviert. Hoffentlich können wir uns bald über ein neues Mitglied freuen :-)",
self.name
),
"Scheckbuch fertig",
None,None
)
.await;
Ok(()) Ok(())
} }
@ -971,14 +955,43 @@ ORDER BY last_access DESC
db: &mut Transaction<'_, Sqlite>, db: &mut Transaction<'_, Sqlite>,
smtp_pw: &str, smtp_pw: &str,
) { ) {
if self.has_role_tx(db, "scheckbuch").await if self.has_role_tx(db, "scheckbuch").await {
&& Logbook::completed_with_user_tx(db, &self).await.len() == 5 let amount_trips = Logbook::completed_with_user_tx(db, &self).await.len();
{ if amount_trips == 5 {
if let Some(mail) = &self.mail { if let Some(mail) = &self.mail {
let _ = self.send_end_mail_scheckbuch(db, mail, smtp_pw).await; let _ = self.send_end_mail_scheckbuch(db, mail, smtp_pw).await;
} }
let coxes = Role::find_by_name_tx(db, "cox").await.unwrap();
Notification::create_for_role_tx(
db,
&coxes,
&format!(
"Liebe Steuerberechtigte, {} hat alle Ausfahrten des Scheckbuchs absolviert. Hoffentlich können wir uns bald über ein neues Mitglied freuen :-)",
self.name
),
"Scheckbuch fertig",
None,None
)
.await;
} else if amount_trips > 5 {
let board = Role::find_by_name_tx(db, "Vorstand").await.unwrap();
Notification::create_for_role_tx(
db,
&board,
&format!(
"Lieber Vorstand, {} hat nun bereits die {}. seiner 5 Scheckbuchausfahrten absolviert.",
self.name, amount_trips
),
"Scheckbuch überfertig",
None,None
)
.await;
} }
} }
// TODO: check fahrtenabzeichen fertig?
// TODO: check äquatorpreis geschafft?
}
} }
#[async_trait] #[async_trait]