show notification to vorstand if boat entry with 'externes boot' or on multiple days is entered
This commit is contained in:
@ -5,7 +5,9 @@ use rocket::FromForm;
|
||||
use serde::Serialize;
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use super::{boat::Boat, log::Log, notification::Notification, rower::Rower, user::User};
|
||||
use super::{
|
||||
boat::Boat, log::Log, notification::Notification, role::Role, rower::Rower, user::User,
|
||||
};
|
||||
|
||||
#[derive(FromRow, Serialize, Clone, Debug)]
|
||||
pub struct Logbook {
|
||||
@ -560,6 +562,31 @@ ORDER BY departure DESC
|
||||
.execute(db.deref_mut())
|
||||
.await.unwrap(); //TODO: fixme
|
||||
|
||||
let duration = arr - dep;
|
||||
if duration.num_days() > 0 {
|
||||
let vorstand = Role::find_by_name_tx(db, "Vorstand").await.unwrap();
|
||||
|
||||
Notification::create_for_role_tx(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!("'{}' hat eine mehrtägige Ausfahrt vom {} bis {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,log.departure, log.arrival, log.distance_in_km, log.destination, log.comments.clone().unwrap_or("".into())),
|
||||
"Mehrtägige Ausfahrt eingetragen",
|
||||
None,
|
||||
).await;
|
||||
}
|
||||
|
||||
if boat.name == "Externes Boot" {
|
||||
let vorstand = Role::find_by_name_tx(db, "Vorstand").await.unwrap();
|
||||
|
||||
Notification::create_for_role_tx(
|
||||
db,
|
||||
&vorstand,
|
||||
&format!("'{}' hat eine Ausfahrt mit *Externem Boot* am {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,log.departure,log.distance_in_km, log.destination, log.comments.unwrap_or("".into())),
|
||||
"Ausfahrt mit externem Boot eingetragen",
|
||||
None,
|
||||
).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user