log event updates
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
Philipp Hofer 2025-04-29 20:36:32 +02:00
parent f1423b8713
commit 8059e5b8fc
2 changed files with 17 additions and 3 deletions

View File

@ -313,7 +313,7 @@ WHERE trip_details.id=?
} }
//TODO: create unit test //TODO: create unit test
pub async fn update(&self, db: &SqlitePool, update: &EventUpdate<'_>) { pub async fn update(&self, db: &SqlitePool, user: &EventUser, update: &EventUpdate<'_>) {
sqlx::query!( sqlx::query!(
"UPDATE planned_event SET name = ?, planned_amount_cox = ? WHERE id = ?", "UPDATE planned_event SET name = ?, planned_amount_cox = ? WHERE id = ?",
update.name, update.name,
@ -340,6 +340,20 @@ WHERE trip_details.id=?
.await .await
.unwrap(); //Okay, as planned_event can only be created with proper DB backing .unwrap(); //Okay, as planned_event can only be created with proper DB backing
Log::create(
db,
format!(
"{} updated the event {} on {} at {} from {:?} to {:?}",
user.user.name,
self.name,
tripdetails.day,
tripdetails.planned_starting_time,
self,
update
),
)
.await;
if !tripdetails.always_show && update.always_show { if !tripdetails.always_show && update.always_show {
Self::advertise( Self::advertise(
db, db,

View File

@ -65,7 +65,7 @@ struct UpdateEventForm<'r> {
async fn update( async fn update(
db: &State<SqlitePool>, db: &State<SqlitePool>,
data: Form<UpdateEventForm<'_>>, data: Form<UpdateEventForm<'_>>,
_admin: EventUser, user: EventUser,
) -> Flash<Redirect> { ) -> Flash<Redirect> {
let update = event::EventUpdate { let update = event::EventUpdate {
name: data.name, name: data.name,
@ -78,7 +78,7 @@ async fn update(
}; };
match Event::find_by_id(db, data.id).await { match Event::find_by_id(db, data.id).await {
Some(planned_event) => { Some(planned_event) => {
planned_event.update(db, &update).await; planned_event.update(db, &user, &update).await;
Flash::success(Redirect::to("/planned"), "Event erfolgreich bearbeitet") Flash::success(Redirect::to("/planned"), "Event erfolgreich bearbeitet")
} }
None => Flash::error(Redirect::to("/planned"), "Planned event id not found"), None => Flash::error(Redirect::to("/planned"), "Planned event id not found"),