From 7ebbf5661aff154e82ac69e1bf9a3d6d329ce411 Mon Sep 17 00:00:00 2001 From: philipp <philipp@hofer.link> Date: Sun, 14 Apr 2024 20:20:22 +0200 Subject: [PATCH] don't show external boats in boatstat; hide logout in menu; move owner into own column in boatstat --- src/model/stat.rs | 6 ++-- templates/includes/macros.html.tera | 55 ++++++++++------------------- templates/stat.boats.html.tera | 2 ++ 3 files changed, 24 insertions(+), 39 deletions(-) diff --git a/src/model/stat.rs b/src/model/stat.rs index 7199ce8..e738a3e 100644 --- a/src/model/stat.rs +++ b/src/model/stat.rs @@ -17,6 +17,7 @@ pub struct BoatStat { pub struct SingleBoatStat { name: String, location: String, + owner: String, years: HashMap<String, i32>, } @@ -39,7 +40,7 @@ LEFT JOIN LEFT JOIN location ON boat.location_id = location.id WHERE - boat.name != 'Externes Boot' + boat.name != 'Externes Boot' AND not boat.external GROUP BY boat.id, year ORDER BY @@ -58,7 +59,7 @@ ORDER BY } else { String::from("Verein") }; - let name = format!("{} ({})", boat.name, owner); + let name = boat.name.clone(); let location: String = row.get("location"); let year: i32 = row.get("year"); if year == 0 { @@ -78,6 +79,7 @@ ORDER BY .or_insert(SingleBoatStat { name, location, + owner, years: HashMap::new(), }); boat_stat.years.insert(year, rowed_km); diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 9caa809..42c9583 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -34,23 +34,6 @@ </a> </div> <div> - {% if "scheckbuch" in loggedin_user.roles and loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %} - <a href="#" - class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer" - data-sidebar="true" - data-trigger="sidebar" - data-header="Ergo Challenge" - data-body="#mobile-menu-guest"> - {% include "includes/book" %} - <span class="sr-only">Ergo</span> - </a> - <div class="hidden"> - <div id="mobile-menu-guest"> - <a href="/ergo" class="block w-100 py-2 hover:text-primary-600 border-t">Ergo</a> - </div> - </div> - {% endif %} - {% if "scheckbuch" not in loggedin_user.roles %} <a href="#" class="inline-flex justify-center rounded-md bg-primary-600 mx-1 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer" data-sidebar="true" @@ -62,34 +45,32 @@ </a> <div class="hidden"> <div id="mobile-menu"> + {% if "Donau Linz" in loggedin_user.roles %} <a href="/planned" class="block w-100 py-2 hover:text-primary-600">Geplante Ausfahrten</a> <a href="/log" class="block w-100 py-2 hover:text-primary-600 border-t">Ausfahrt eintragen</a> <a href="/log/show" class="block w-100 py-2 hover:text-primary-600 border-t">Logbuch</a> - {% if "admin" in loggedin_user.roles or "Vorstand" in loggedin_user.roles %} - <a href="/admin/user" - class="block w-100 py-2 hover:text-primary-600 border-t">Userverwaltung</a> - {% endif %} - {% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %} - <a href="/ergo" class="block w-100 py-2 hover:text-primary-600 border-t">Ergo</a> - {% endif %} <a href="/stat" class="block w-100 py-2 hover:text-primary-600 border-t">Statistik</a> <a href="/stat/boats" class="block w-100 py-2 hover:text-primary-600 border-t">Bootsauswertung</a> - {% if "admin" in loggedin_user.roles %} - <a href="/admin/boat" - class="block w-100 py-2 hover:text-primary-600 border-t">Boote</a> - {% endif %} <a href="/boatdamage" class="block w-100 py-2 hover:text-primary-600 border-t">Bootsschaden</a> <a href="/boatreservation" class="block w-100 py-2 hover:text-primary-600 border-t">Bootsreservierung</a> - </div> - </div> - {% endif %} - <a href="/auth/logout" - class="inline-flex justify-center rounded-md bg-gray-200 ml-1 px-3 py-2 text-sm font-semibold text-primary-950 hover:bg-gray-300 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer"> - <svg class="inline h-4" + {% endif %} + {% if loggedin_user.weight and loggedin_user.sex and loggedin_user.dob %} + <a href="/ergo" class="block w-100 py-2 hover:text-primary-600 border-t">Ergo</a> + {% endif %} + {% if "admin" in loggedin_user.roles or "Vorstand" in loggedin_user.roles %} + <a href="/admin/user" + class="block w-100 py-2 hover:text-primary-600 border-t">Userverwaltung</a> + {% endif %} + {% if "admin" in loggedin_user.roles %} + <a href="/admin/boat" + class="block w-100 py-2 hover:text-primary-600 border-t">Boote</a> + {% endif %} + <a href="/auth/logout" + class="block w-100 py-2 hover:text-primary-600 border-t">Ausloggen<svg class="inline h-4" width="24" height="24" viewbox="0 0 24 24" @@ -102,9 +83,9 @@ <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path> <polyline points="16 17 21 12 16 7"></polyline> <line x1="21" y1="12" x2="9" y2="12"></line> - </svg> - <span class="sr-only">Ausloggen</span> - </a> + </svg></a> + </div> + </div> </div> </div> </header> diff --git a/templates/stat.boats.html.tera b/templates/stat.boats.html.tera index d9c3af7..5c6a0d4 100644 --- a/templates/stat.boats.html.tera +++ b/templates/stat.boats.html.tera @@ -9,6 +9,7 @@ <thead> <tr> <th>Name</th> + <th>Eigentümer</th> <th>Ort</th> {% for year in stat.pot_years | sort | reverse %}<th>{{ year }}</th>{% endfor %} </tr> @@ -17,6 +18,7 @@ {% for boat in stat.boats %} <tr> <td>{{ boat.name }}</td> + <td>{{ boat.owner }}</td> <td>{{ boat.location }}</td> {% for year in stat.pot_years | sort | reverse %} <td>