From 87307378c6225fd50b78efe0eb74b1e7a34535ef Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 24 Apr 2024 17:15:53 +0200 Subject: [PATCH 1/2] no special treatment for 'externes boot' --- src/model/boat.rs | 2 +- src/model/logbook.rs | 4 ++-- src/model/stat.rs | 4 ++-- src/tera/board/boathouse.rs | 2 +- templates/includes/forms/log.html.tera | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/model/boat.rs b/src/model/boat.rs index 015a54c..cb13121 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -27,7 +27,7 @@ pub struct Boat { #[serde(default = "bool::default")] skull: bool, #[serde(default = "bool::default")] - external: bool, + pub external: bool, pub deleted: bool, } diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 156ad8e..388393f 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -582,13 +582,13 @@ ORDER BY departure DESC ).await; } - if boat.name == "Externes Boot" { + if boat.external { let vorstand = Role::find_by_name_tx(db, "Vorstand").await.unwrap(); Notification::create_for_role_tx( db, &vorstand, - &format!("'{}' hat eine Ausfahrt mit *Externem Boot* am {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,log.departure,log.distance_in_km, log.destination, log.comments.unwrap_or("".into())), + &format!("'{}' hat eine Ausfahrt mit externem Boot '{}' am {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,boat.name,log.departure,log.distance_in_km, log.destination, log.comments.unwrap_or("".into())), "Ausfahrt mit externem Boot eingetragen", None, ).await; diff --git a/src/model/stat.rs b/src/model/stat.rs index e738a3e..0398115 100644 --- a/src/model/stat.rs +++ b/src/model/stat.rs @@ -40,7 +40,7 @@ LEFT JOIN LEFT JOIN location ON boat.location_id = location.id WHERE - boat.name != 'Externes Boot' AND not boat.external + not boat.external GROUP BY boat.id, year ORDER BY @@ -115,7 +115,7 @@ LEFT JOIN ( FROM rower GROUP BY logbook_id ) m ON l.id = m.logbook_id -WHERE l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%' AND b.name != 'Externes Boot'; +WHERE l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%' AND not b.external; " )) .fetch_one(db) diff --git a/src/tera/board/boathouse.rs b/src/tera/board/boathouse.rs index fbaa16c..54fd729 100644 --- a/src/tera/board/boathouse.rs +++ b/src/tera/board/boathouse.rs @@ -27,7 +27,7 @@ async fn index( let boats = Boat::all_for_boatshouse(db).await; let mut final_boats = Vec::new(); for boat in boats { - if boat.boat.boathouse(db).await.is_none() && boat.boat.name != "Externes Boot" { + if boat.boat.boathouse(db).await.is_none() && !boat.boat.external { final_boats.push(boat); } } diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 59a2c4f..da17d5c 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -228,9 +228,9 @@ {{ rower.name }} {%- if rower.id == log.steering_user.id and rower.id != log.shipmaster_user.id %} (Steuerperson){%- endif -%} - {%- if not loop.last or amount_guests > 0 and log.boat.name != 'Externes Boot' %},{% endif %} + {%- if not loop.last or amount_guests > 0 and not log.boat.external %},{% endif %} {% endfor -%} - {% if amount_guests > 0 and log.boat.name != 'Externes Boot' %} + {% if amount_guests > 0 and not log.boat.external %} Gäste (ohne Account): {{ amount_guests }} -- 2.45.2 From 5eadfd42bb26459038e3d0ac6683bdb651f11ae5 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 24 Apr 2024 17:18:57 +0200 Subject: [PATCH 2/2] don't show link if the user has no permission --- templates/board/boathouse.html.tera | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/board/boathouse.html.tera b/templates/board/boathouse.html.tera index 5f9e3b7..29e5665 100644 --- a/templates/board/boathouse.html.tera +++ b/templates/board/boathouse.html.tera @@ -7,8 +7,11 @@ {% set aisle = aisle_name ~ "-aisle" %} {% set place = boathouse[aisle][side_name] %} {% if place[level] %} - {{ place[level].1.name }} X + {{ place[level].1.name }} + {% if "admin" in loggedin_user.roles %} + X + {% endif %} {% elif boats | length > 0 %} {% if "admin" in loggedin_user.roles %}
-- 2.45.2