From 7cbfafa5c5ff9c711cd43bbe3a53a8e75c475dd0 Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 7 Apr 2024 22:12:56 +0200 Subject: [PATCH] better text for boat reservation --- src/model/boatreservation.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/model/boatreservation.rs b/src/model/boatreservation.rs index c20e841..311f966 100644 --- a/src/model/boatreservation.rs +++ b/src/model/boatreservation.rs @@ -126,15 +126,23 @@ WHERE end_date >= CURRENT_DATE ORDER BY end_date let board = User::all_with_role(db, &Role::find_by_name(db, "Vorstand").await.unwrap()).await; for user in board { + let date = if boatreservation.start_date == boatreservation.end_date { + format!("am {}", boatreservation.start_date) + } else { + format!( + "von {} bis {}", + boatreservation.start_date, boatreservation.end_date + ) + }; + Notification::create( db, &user, &format!( - "{} hat eine neue Bootsreservierung für Boot '{}' angelegt: Von {} bis {} um {} wegen {}", + "{} hat eine neue Bootsreservierung für Boot '{}' {} angelegt. Zeit: {}; Zweck: {}", boatreservation.user_applicant.name, boatreservation.boat.name, - boatreservation.start_date, - boatreservation.end_date, + date, boatreservation.time_desc, boatreservation.usage ),