use render trait
All checks were successful
CI/CD Pipeline / test (push) Successful in 5m42s
CI/CD Pipeline / deploy (push) Successful in 3m50s

This commit is contained in:
Philipp Hofer 2025-04-20 23:03:35 +02:00
parent f5a2901b16
commit ffbcf04da7
3 changed files with 18 additions and 14 deletions

View File

@ -43,14 +43,7 @@ async fn highscore(State(db): State<Arc<SqlitePool>>, session: Session) -> Marku
td { "Team" } td { "Team" }
@for station in route.stations(&db).await { @for station in route.stations(&db).await {
td { td {
a href=(format!("/admin/station/{}", station.id)){ (station)
(station.name)
@if station.crewless() {
em data-tooltip="Station ohne Stationsbetreuer" data-placement="bottom" {
small { "🤖" }
}
}
}
} }
} }
td { "Gesamtpunkte" } td { "Gesamtpunkte" }

View File

@ -161,12 +161,7 @@ async fn view(
ol { ol {
@for (idx, station) in cur_stations.into_iter().enumerate() { @for (idx, station) in cur_stations.into_iter().enumerate() {
li { li {
(station.name) (station)
@if station.crewless() {
em data-tooltip="Station ohne Stationsbetreuer" {
small { "🤖" }
}
}
@if idx > 0 { @if idx > 0 {
a href=(format!("/admin/route/{}/move-station-higher/{}", route.id, station.id)){ a href=(format!("/admin/route/{}/move-station-higher/{}", route.id, station.id)){
em data-tooltip=(format!("{} nach vor reihen", station.name)) { em data-tooltip=(format!("{} nach vor reihen", station.name)) {

View File

@ -6,6 +6,7 @@ use crate::{
}; };
use axum::Router; use axum::Router;
use chrono::{DateTime, Local, NaiveDateTime, Utc}; use chrono::{DateTime, Local, NaiveDateTime, Utc};
use maud::{html, Markup, Render};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool}; use sqlx::{FromRow, SqlitePool};
@ -24,6 +25,21 @@ pub(crate) struct Station {
pub(crate) lng: Option<f64>, pub(crate) lng: Option<f64>,
} }
impl Render for Station {
fn render(&self) -> Markup {
html! {
a href=(format!("/admin/station/{}", self.id)){
(self.name)
}
@if self.crewless() {
em data-tooltip="Station ohne Stationsbetreuer" data-placement="bottom" {
small { "🤖" }
}
}
}
}
}
impl Station { impl Station {
pub(crate) async fn all(db: &SqlitePool) -> Vec<Self> { pub(crate) async fn all(db: &SqlitePool) -> Vec<Self> {
sqlx::query_as::<_, Self>( sqlx::query_as::<_, Self>(