From 237377dc05ddbb77e50c0982bcd92a3fccea53a7 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 24 Apr 2024 16:56:48 +0200 Subject: [PATCH] easier handling of external boats, show all in separate category --- src/model/boat.rs | 18 +++++++++++------- templates/includes/forms/log.html.tera | 10 ++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/model/boat.rs b/src/model/boat.rs index 115acec..015a54c 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -180,10 +180,14 @@ AND date('now') BETWEEN start_date AND end_date;", if boat.is_locked(db).await { damage = BoatDamage::Locked; } - let cat = if boat.default_shipmaster_only_steering { - format!("{}+", boat.amount_seats - 1) + let cat = if boat.external { + format!("Vereinsfremde Boote") } else { - format!("{}x", boat.amount_seats) + if boat.default_shipmaster_only_steering { + format!("{}+", boat.amount_seats - 1) + } else { + format!("{}x", boat.amount_seats) + } }; res.push(BoatWithDetails { @@ -259,7 +263,7 @@ ORDER BY " SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat -WHERE owner is null or owner = ? +WHERE (owner is null or owner = ?) AND deleted = 0 ORDER BY amount_seats DESC ", user.id @@ -273,7 +277,7 @@ ORDER BY amount_seats DESC " SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat -WHERE owner = ? OR (owner is null and amount_seats = 1) +WHERE (owner = ? OR (owner is null and amount_seats = 1)) AND deleted = 0 ORDER BY amount_seats DESC ", user.id @@ -291,7 +295,7 @@ ORDER BY amount_seats DESC Boat, "SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat -WHERE owner is null and location_id = ? +WHERE (owner is null and location_id = ?) AND deleted = 0 ORDER BY amount_seats DESC ",ottensheim.id) .fetch_all(db) @@ -311,7 +315,7 @@ ORDER BY amount_seats DESC SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat INNER JOIN location ON boat.location_id = location.id -WHERE location.name=? +WHERE location.name=? AND deleted = 0 ORDER BY amount_seats DESC ", location diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index c70fb8c..59a2c4f 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -3,16 +3,10 @@ Inputs: boats #} {% macro show_boats() %} - {% for amount_seats, grouped_boats in boats | group_by(attribute="cat") %} + {% for cat, grouped_boats in boats | group_by(attribute="cat") %}
- - {% if grouped_boats[0].external %} - Vereinsfremde Boote - {% else %} - {{ grouped_boats[0].cat }} - {% endif %} - + {{ cat }} ({{ grouped_boats | length }})