From eb49a829c627ab686e677427b60a258f5646e241 Mon Sep 17 00:00:00 2001
From: Philipp Hofer
Date: Mon, 11 Nov 2024 10:27:50 +0100
Subject: [PATCH 1/2] formatting ergo
---
templates/ergo/final.html.tera | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/templates/ergo/final.html.tera b/templates/ergo/final.html.tera
index 74dd7a9..8dc4731 100644
--- a/templates/ergo/final.html.tera
+++ b/templates/ergo/final.html.tera
@@ -7,13 +7,15 @@
Dirty Thirty
- {% for stat in thirty %}
- {% set names = stat.name | split(pat=" ") %}{% set lastname_index = names | length - 1 %}{% set lastname = names[lastname_index] %}{{ lastname }}
- {% for name in names %}
+
@@ -21,17 +23,15 @@
Dirty Dozen
- {% for stat in dozen %}
- {% set names = stat.name | split(pat=" ") %}
- {% set lastname_index = names | length - 1 %}
- {% set lastname = names[lastname_index] %}
- {{ lastname }};
- {% for name in names %}
+
--
2.45.2
From d5e6371b897bd27d8d260af328300a52e4ef2b57 Mon Sep 17 00:00:00 2001
From: Philipp Hofer
Date: Mon, 11 Nov 2024 13:33:23 +0100
Subject: [PATCH 2/2] craete log if user creates a new event
---
src/model/event.rs | 18 ++++++++++++++++--
src/tera/admin/event.rs | 3 ++-
2 files changed, 18 insertions(+), 3 deletions(-)
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,
data: Form>,
- _admin: EventUser,
+ user: EventUser,
) -> Flash {
let data = data.into_inner();
@@ -37,6 +37,7 @@ async fn create(
Event::create(
db,
+ &user,
data.name,
data.planned_amount_cox,
data.always_show,
--
2.45.2