diff --git a/src/model/event.rs b/src/model/event.rs
index cf5917d..a48d18e 100644
--- a/src/model/event.rs
+++ b/src/model/event.rs
@@ -9,8 +9,12 @@ use serde::Serialize;
use sqlx::{FromRow, Row, SqlitePool};
use super::{
- notification::Notification, role::Role, tripdetails::TripDetails, triptype::TripType,
- user::User,
+ log::Log,
+ notification::Notification,
+ role::Role,
+ tripdetails::TripDetails,
+ triptype::TripType,
+ user::{EventUser, User},
};
#[derive(Serialize, Clone, FromRow, Debug, PartialEq)]
@@ -242,6 +246,7 @@ WHERE trip_details.id=?
pub async fn create(
db: &SqlitePool,
+ user: &EventUser,
name: &str,
planned_amount_cox: i32,
always_show: bool,
@@ -270,6 +275,15 @@ WHERE trip_details.id=?
.execute(db)
.await
.unwrap(); //Okay, as TripDetails can only be created with proper DB backing
+
+ Log::create(
+ db,
+ format!(
+ "{} created event {} on {} at {}.",
+ user.user.name, name, trip_details.day, trip_details.planned_starting_time
+ ),
+ )
+ .await;
}
//TODO: create unit test
diff --git a/src/tera/admin/event.rs b/src/tera/admin/event.rs
index ef97fc6..e78c465 100644
--- a/src/tera/admin/event.rs
+++ b/src/tera/admin/event.rs
@@ -26,7 +26,7 @@ struct AddEventForm<'r> {
async fn create(
db: &State