Compare commits

...

2 Commits

Author SHA1 Message Date
56f5b6e8db Merge pull request 'inform board if more trips than allowed' (#744) from mail-end-scheckbuch into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 11m2s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 9m10s
Reviewed-on: #744
2024-09-12 08:36:20 +02:00
b429998775 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
2024-09-12 08:35:10 +02:00

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,13 +955,42 @@ 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?
} }
} }