diff --git a/README.md b/README.md index e9e966b..453c76e 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,7 @@ ## New large features ### Logbuch Next: -- Make boats updateable (incl. rower + location) -- Write tests for model/boat.rs +- Start with CREATE for logbook ### Guest-Scheckbuch - guest_trip 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: