send scheckbuch people mail after using all trips
This commit is contained in:
@ -15,18 +15,21 @@ use rocket_dyn_templates::{context, Template};
|
||||
use sqlx::SqlitePool;
|
||||
use tera::Context;
|
||||
|
||||
use crate::model::{
|
||||
boat::Boat,
|
||||
boatreservation::BoatReservation,
|
||||
distance::Distance,
|
||||
log::Log,
|
||||
logbook::{
|
||||
LogToAdd, LogToFinalize, LogToUpdate, Logbook, LogbookAdminUpdateError, LogbookCreateError,
|
||||
LogbookDeleteError, LogbookUpdateError,
|
||||
use crate::{
|
||||
model::{
|
||||
boat::Boat,
|
||||
boatreservation::BoatReservation,
|
||||
distance::Distance,
|
||||
log::Log,
|
||||
logbook::{
|
||||
LogToAdd, LogToFinalize, LogToUpdate, Logbook, LogbookAdminUpdateError,
|
||||
LogbookCreateError, LogbookDeleteError, LogbookUpdateError,
|
||||
},
|
||||
logtype::LogType,
|
||||
trip::Trip,
|
||||
user::{AdminUser, DonauLinzUser, User, UserWithDetails, VorstandUser},
|
||||
},
|
||||
logtype::LogType,
|
||||
trip::Trip,
|
||||
user::{AdminUser, DonauLinzUser, User, UserWithDetails, VorstandUser},
|
||||
tera::Config,
|
||||
};
|
||||
|
||||
pub struct KioskCookie(());
|
||||
@ -210,11 +213,12 @@ async fn create_logbook(
|
||||
db: &SqlitePool,
|
||||
data: Form<LogToAdd>,
|
||||
user: &DonauLinzUser,
|
||||
smtp_pw: &str,
|
||||
) -> Flash<Redirect> {
|
||||
match Logbook::create(
|
||||
db,
|
||||
data.into_inner(),
|
||||
user
|
||||
user, smtp_pw
|
||||
)
|
||||
.await
|
||||
{
|
||||
@ -244,6 +248,7 @@ async fn create(
|
||||
db: &State<SqlitePool>,
|
||||
data: Form<LogToAdd>,
|
||||
user: DonauLinzUser,
|
||||
config: &State<Config>,
|
||||
) -> Flash<Redirect> {
|
||||
Log::create(
|
||||
db,
|
||||
@ -251,7 +256,7 @@ async fn create(
|
||||
)
|
||||
.await;
|
||||
|
||||
create_logbook(db, data, &user).await
|
||||
create_logbook(db, data, &user, &config.smtp_pw).await
|
||||
}
|
||||
|
||||
#[post("/", data = "<data>")]
|
||||
@ -259,6 +264,7 @@ async fn create_kiosk(
|
||||
db: &State<SqlitePool>,
|
||||
data: Form<LogToAdd>,
|
||||
_kiosk: KioskCookie,
|
||||
config: &State<Config>,
|
||||
) -> Flash<Redirect> {
|
||||
let Some(boat) = Boat::find_by_id(db, data.boat_id).await else {
|
||||
return Flash::error(Redirect::to("/log"), "Boot gibt's nicht");
|
||||
@ -287,7 +293,13 @@ async fn create_kiosk(
|
||||
)
|
||||
.await;
|
||||
|
||||
create_logbook(db, data, &DonauLinzUser::new(db, creator).await.unwrap()).await
|
||||
create_logbook(
|
||||
db,
|
||||
data,
|
||||
&DonauLinzUser::new(db, creator).await.unwrap(),
|
||||
&config.smtp_pw,
|
||||
)
|
||||
.await
|
||||
//TODO: fixme
|
||||
}
|
||||
|
||||
@ -331,6 +343,7 @@ async fn home_logbook(
|
||||
data: Form<LogToFinalize>,
|
||||
logbook_id: i64,
|
||||
user: &DonauLinzUser,
|
||||
smtp_pw: &str,
|
||||
) -> Flash<Redirect> {
|
||||
let logbook: Option<Logbook> = Logbook::find_by_id(db, logbook_id).await;
|
||||
let Some(logbook) = logbook else {
|
||||
@ -340,7 +353,7 @@ async fn home_logbook(
|
||||
);
|
||||
};
|
||||
|
||||
match logbook.home(db,user, data.into_inner()).await {
|
||||
match logbook.home(db,user, data.into_inner(), smtp_pw).await {
|
||||
Ok(_) => Flash::success(Redirect::to("/log"), "Ausfahrt korrekt eingetragen"),
|
||||
Err(LogbookUpdateError::TooManyRowers(expected, actual)) => Flash::error(Redirect::to("/log"), format!("Zu viele Ruderer (Boot fasst maximal {expected}, es wurden jedoch {actual} Ruderer ausgewählt)")),
|
||||
Err(LogbookUpdateError::OnlyAllowedToEndTripsEndingToday) => Flash::error(Redirect::to("/log"), "Nur Ausfahrten, die heute enden dürfen eingetragen werden. Für einen Nachtrag schreibe alle Daten Philipp (Tel. nr. siehe Signal oder it@rudernlinz.at)."),
|
||||
@ -361,6 +374,7 @@ async fn home_kiosk(
|
||||
data: Form<LogToFinalize>,
|
||||
logbook_id: i64,
|
||||
_kiosk: KioskCookie,
|
||||
config: &State<Config>,
|
||||
) -> Flash<Redirect> {
|
||||
let logbook = Logbook::find_by_id(db, logbook_id).await.unwrap(); //TODO: fixme
|
||||
|
||||
@ -382,6 +396,7 @@ async fn home_kiosk(
|
||||
)
|
||||
.await
|
||||
.unwrap(),
|
||||
&config.smtp_pw,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@ -392,6 +407,7 @@ async fn home(
|
||||
data: Form<LogToFinalize>,
|
||||
logbook_id: i64,
|
||||
user: DonauLinzUser,
|
||||
config: &State<Config>,
|
||||
) -> Flash<Redirect> {
|
||||
Log::create(
|
||||
db,
|
||||
@ -402,7 +418,7 @@ async fn home(
|
||||
)
|
||||
.await;
|
||||
|
||||
home_logbook(db, data, logbook_id, &user).await
|
||||
home_logbook(db, data, logbook_id, &user, &config.smtp_pw).await
|
||||
}
|
||||
|
||||
#[get("/<logbook_id>/delete", rank = 2)]
|
||||
|
Reference in New Issue
Block a user