From b2f626f906948cd14e613dd01044f78c63d1bb5e Mon Sep 17 00:00:00 2001 From: philipp Date: Sat, 22 Jul 2023 16:36:02 +0200 Subject: [PATCH] allow creating all fields for new boats --- src/model/boat.rs | 19 +++++++++++++------ src/tera/admin/boat.rs | 4 ++++ templates/admin/boat/index.html.tera | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/model/boat.rs b/src/model/boat.rs index e791c1d..128fa8d 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -72,20 +72,23 @@ ORDER BY amount_seats DESC default_shipmaster_only_steering: bool, skull: bool, external: bool, + location_id: Option, + owner: Option, ) -> bool { sqlx::query!( - "INSERT INTO boat(name, amount_seats, year_built, boatbuilder, default_shipmaster_only_steering, skull, external) VALUES (?,?,?,?,?,?,?)", + "INSERT INTO boat(name, amount_seats, year_built, boatbuilder, default_shipmaster_only_steering, skull, external, location_id, owner) VALUES (?,?,?,?,?,?,?,?,?)", name, amount_seats, year_built, boatbuilder, default_shipmaster_only_steering, skull, - external + external, + location_id, + owner ) .execute(db) - .await - .is_ok() + .await.is_ok() } pub async fn update( @@ -167,7 +170,9 @@ mod test { "Best Boatbuilder".into(), true, true, - false + false, + Some(1), + None ) .await, true @@ -187,7 +192,9 @@ mod test { "Best Boatbuilder".into(), true, true, - false + false, + Some(1), + None ) .await, false diff --git a/src/tera/admin/boat.rs b/src/tera/admin/boat.rs index 89af9e1..d69d9df 100644 --- a/src/tera/admin/boat.rs +++ b/src/tera/admin/boat.rs @@ -111,6 +111,8 @@ struct BoatAddForm<'r> { default_shipmaster_only_steering: bool, skull: bool, external: bool, + location_id: Option, + owner: Option, } #[post("/boat/new", data = "")] @@ -128,6 +130,8 @@ async fn create( data.default_shipmaster_only_steering, data.skull, data.external, + data.location_id, + data.owner, ) .await { diff --git a/templates/admin/boat/index.html.tera b/templates/admin/boat/index.html.tera index 1beda21..e799005 100644 --- a/templates/admin/boat/index.html.tera +++ b/templates/admin/boat/index.html.tera @@ -30,6 +30,8 @@ + {{ macros::select(data=locations, label='location', select_name='location_id', selected_id=1) }} + {{ macros::select(data=users, label='users', select_name='owner', default="Vereinsboot") }}
default_shipmaster_only_steering: