log-trip-creation #1075
@ -1,5 +1,6 @@
|
|||||||
use super::Trip;
|
use super::Trip;
|
||||||
use crate::model::{
|
use crate::model::{
|
||||||
|
log::Log,
|
||||||
notification::Notification,
|
notification::Notification,
|
||||||
planned::{tripdetails::TripDetails, triptype::TripType},
|
planned::{tripdetails::TripDetails, triptype::TripType},
|
||||||
user::{ErgoUser, SteeringUser, User},
|
user::{ErgoUser, SteeringUser, User},
|
||||||
@ -34,6 +35,8 @@ impl Trip {
|
|||||||
.execute(db)
|
.execute(db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
Log::create(db, format!("{user} created a new trip: {trip_details}")).await;
|
||||||
|
|
||||||
Self::notify_trips_same_datetime(db, trip_details, user).await;
|
Self::notify_trips_same_datetime(db, trip_details, user).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use super::{
|
|||||||
trip::{Trip, TripWithDetails},
|
trip::{Trip, TripWithDetails},
|
||||||
triptype::TripType,
|
triptype::TripType,
|
||||||
};
|
};
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||||
pub struct TripDetails {
|
pub struct TripDetails {
|
||||||
@ -22,6 +23,20 @@ pub struct TripDetails {
|
|||||||
pub is_locked: bool,
|
pub is_locked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for TripDetails {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str(&format!(
|
||||||
|
"Ausfahrt am {} um {} mit {} Personen",
|
||||||
|
self.day, self.planned_starting_time, self.max_people
|
||||||
|
))?;
|
||||||
|
if let Some(notes) = &self.notes {
|
||||||
|
f.write_str(&format!(" Notizen: {notes}"))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(FromForm, Serialize)]
|
#[derive(FromForm, Serialize)]
|
||||||
pub struct TripDetailsToAdd<'r> {
|
pub struct TripDetailsToAdd<'r> {
|
||||||
//TODO: properly parse `planned_starting_time`
|
//TODO: properly parse `planned_starting_time`
|
||||||
|
Reference in New Issue
Block a user