more external string, continue #12
All checks were successful
CI/CD Pipeline / test (push) Successful in 13m55s
CI/CD Pipeline / deploy (push) Successful in 6m16s

This commit is contained in:
Philipp Hofer 2025-04-22 09:21:04 +02:00
parent a0614726cc
commit 2f6130dd5d
3 changed files with 211 additions and 164 deletions

View File

@ -13,6 +13,85 @@ do_login: "Einloggen"
invalid_credentials: "Falscher Benutzername/Passwort" invalid_credentials: "Falscher Benutzername/Passwort"
login_succ: "Erfolgreich eingeloggt als %{name}" login_succ: "Erfolgreich eingeloggt als %{name}"
user_id_nonexisting: "User mit ID %{id} gibts ned" user_id_nonexisting: "User mit ID %{id} gibts ned"
person: "Person"
people: "Personen"
#
# ######
# # # ###### # # ###### ##### ##### # # # # ####
# # # # # # # # # # # # ## # # #
# ###### ##### # # ##### # # # # # # # # #
# # # # # ## # # ##### # # # # # # # ###
# # # # ## ## # # # # # # # ## # #
# ###### ###### # # ###### # # # #### # # ####
#
invalid_rating_code: "Falscher Quick-Login-Link. Bitte nochmal scannen oder neu eingeben."
infos: "Infos"
station_has_no_teams_to_take_to_start: "Du musst keine Teams zu deiner Station mitnehmen."
station_should_take_one_teams_to_start: "Nimm bitte folgendes Team am Anfang zu deiner Station mit:"
station_should_take_n_teams_to_start: "Nimm bitte folgende %{amount} Teams am Anfang zu deiner Station mit:"
your_station_is_here: "Hier befindet sich deine Station:"
station_ready: "Ich bin bei meiner Station und bereit zu starten!"
station_not_yet_ready: "Bin mit der Station doch noch nicht bereit..."
one_team_should_come_to_station: "Insgesamt sollte 1 Team zu deiner Station kommen."
n_teams_should_come_to_station: "Insgesamt sollten %{amount} Teams zu deiner Station kommen."
team_on_the_way_to_your_station: "Team %{team} ist seit %{time} auf dem Weg zu deiner Station."
team_is_here: "Team ist da"
info_single_team_not_yet_rated: "Noch keine Punkte für diese Gruppe vergeben ⤵️"
info_multiple_teams_not_yet_rated: "Noch keine Punkte für diese Gruppen vergeben ⤵️"
points: "Punkte"
confirm_rating_change: "Du hast die Gruppe bereits bewertet. Bist du sicher, dass du deine Bewertung nochmal ändern möchtest?"
no_teams_rated_yet: "Du hast bisher noch keine Teams bewertet."
succ_change: "Erfolgreich geändert"
cant_add_nonexisting_team_to_waiting: "Konnte das Team der Warteschlange nicht hinzufügen, weil ein Team mit ID %{id} nicht existiert"
cant_add_team_to_waiting_not_in_your_route: "Konnte das Team %{team} der Warteschlange nicht hinzufügen, weil das Team nicht zu deiner Station kommen soll."
cant_add_nonexisting_team_to_active: "Das Team kann nicht starten, weil ein Team mit ID %{id} nicht existiert"
cant_add_nonexisting_team_to_finished: "Das Team kann nicht beenden, weil ein Team mit ID %{id} nicht existiert"
team_added_to_waiting: "Team %{team} wurde der Warteschlange hinzugefügt."
team_added_to_active: "Team %{team} performt aktuell bei deiner Station."
team_added_to_finished: "Team %{team} erfolgreich beendet."
team_removed_from_waiting: "Team %{team} wurde von der Warteschlange entfernt."
team_removed_from_active: "Team %{team} performt doch nicht bei dir."
team_removed_from_finished: "Team %{team} arbeitet wieder an deiner Station."
rating_updated: "Bewertung für Team %{team} wurde aktualisiert."
cant_remove_nonexisting_team_from_waiting: "Konnte das Team nicht von der Warteschlange entfernen, weil ein Team mit ID %{id} nicht existiert"
cant_remove_nonexisting_team_from_active: "Konnte das Team nicht von deiner Station entfernen, weil ein Team mit ID %{id} nicht existiert"
cant_remove_nonexisting_team_from_finished: "Konnte das Team nicht von deinen Bewertungen entfernen, weil ein Team mit ID %{id} nicht existiert"
cant_remove_team_from_waiting_not_there: "Konnte das Team %{team} nicht von der Warteschlange entfernen, weil es nicht in der Warteschlange ist."
team_cant_start_not_in_waiting: "Team %{team} kann nicht starten, weil es nicht in der Warteschlange ist."
team_cant_finish_not_in_active: "Team %{team} kann nicht beenden, weil es nicht arbeitet."
team_removal_active_not_possible_not_there: "Team %{team} kann nicht von der Startliste gelöscht werden, weil es dort gar nicht ist."
team_removal_left_not_possible_not_there: "Team %{team} kann nicht von der Bewertungsliste gelöscht werden, weil es dort gar nicht ist."
cant_update_nonexisting_team: "Konnte die Teambewertung nicht aktualisieren, weil ein Team mit ID %{id} nicht existiert"
can_only_update_ratings_for_teams_which_were_at_your_station: "Es können nur Teams bewertet werden, die zumindest schon bei der Station sind."
teams_at_your_station: "Teams bei dir"
to_rate: "Noch zu bewerten"
history: "Was bisher geschah"
state_active: "Aktiv"
state_active_icon: "🎬"
state_waiting: "Wartend"
state_waiting_icon: "⏳"
state_to_rate: "Zu bewerten"
state_to_rate_icon: "☐"
state_rated: "Schon bewertet"
state_rated_icon: "✅"
since_time: "seit %{time}"
left_at: "um %{time} gegangen"
arrived_at_started_at_left_at: "um %{arrived} eingetroffen, um %{active} gestarted und um %{left} gegangen"
team_finished: "Team fertig"
team_starting: "Team startet"
notes: "Notizen"
save_notes: "Notizen speichern"
confirm_station_cancel_team_active: "Bist du sicher, dass das Team %{team} noch nicht bei dir arbeitet? Das Team wird zurück auf die Warte-Position gesetzt"
confirm_station_cancel_team_waiting: "Bist du sicher, dass das Team %{team} noch nicht bei dir ist? Das kann _NICHT_ mehr rückgängig gemacht werden."
confirm_station_cancel_team_finished: "Bist du sicher, dass das Team noch nicht bei dir fertig ist? Das Team wird zurück auf die Arbeits-Position gesetzt."
# #
@ -24,7 +103,9 @@ user_id_nonexisting: "User mit ID %{id} gibts ned"
# # # # # # # # # # # ## # # # # # # # # # # # ##
# ##### # # # # # #### # # # ##### # # # # # #### # #
# #
station: "Station"
stations: "Stationen" stations: "Stationen"
crewless_station: "Station ohne Stationsbetreuer"
station_create: "Station erstellen" station_create: "Station erstellen"
stations_expl_without_first_word: "sind festgelegte Orte mit spezifischen Aufgaben." stations_expl_without_first_word: "sind festgelegte Orte mit spezifischen Aufgaben."
station_warning_not_assigned_route: "Noch keiner Route zugeordnet" # should be short -> tooltip station_warning_not_assigned_route: "Noch keiner Route zugeordnet" # should be short -> tooltip
@ -53,6 +134,7 @@ generate_station_pdf: "Stations PDF generieren"
# #
team: "Team" team: "Team"
teams: "Teams" teams: "Teams"
select_team: "Team auswählen"
go_to_teams: "Zu den Teams" go_to_teams: "Zu den Teams"
not_yet_started: "nocht nicht gestartet" not_yet_started: "nocht nicht gestartet"
not_yet_done: "nocht nicht fertig" not_yet_done: "nocht nicht fertig"

View File

@ -35,7 +35,7 @@ impl Render for Station {
(self.name) (self.name)
} }
@if self.crewless() { @if self.crewless() {
em data-tooltip="Station ohne Stationsbetreuer" data-placement="bottom" { em data-tooltip=(t!("crewless_station")) data-placement="bottom" {
small { "🤖" } small { "🤖" }
} }
} }
@ -137,10 +137,11 @@ impl Station {
let teams = TeamsAtStationLocation::for_station(db, self).await; let teams = TeamsAtStationLocation::for_station(db, self).await;
if !teams.not_yet_here.contains(team) { if !teams.not_yet_here.contains(team) {
return Err(format!( return Err(t!(
"Kann Team nicht der Warteschlange hinzufügen, weil das Team {} nicht zu deiner Station kommen soll.", "cant_add_team_to_waiting_not_in_your_route",
team.name team = team.name
)); )
.into());
} }
Rating::create(db, self, team).await?; Rating::create(db, self, team).await?;
@ -177,10 +178,7 @@ impl Station {
&& !finished_teams.contains(&team) && !finished_teams.contains(&team)
&& !finished_and_rated_teams.contains(&team) && !finished_and_rated_teams.contains(&team)
{ {
return Err( return Err(t!("can_only_update_ratings_for_teams_which_were_at_your_station").into());
"Es können nur Teams bewertet werden, die zumindest schon bei der Station sind."
.to_string(),
);
} }
Rating::update(db, self, team, points, notes).await?; Rating::update(db, self, team, points, notes).await?;
@ -198,10 +196,7 @@ impl Station {
let waiting_teams: Vec<&Team> = teams.waiting.iter().map(|(team, _)| team).collect(); let waiting_teams: Vec<&Team> = teams.waiting.iter().map(|(team, _)| team).collect();
if !waiting_teams.contains(&team) { if !waiting_teams.contains(&team) {
return Err(format!( return Err(t!("cant_remove_team_from_waiting_not_there", team = team.name).into());
"Kann Team nicht von der Warteschlange gelöscht werden, weil das Team {} nicht in der Warteschlange ist.",
team.name
));
} }
Rating::delete(db, self, team).await?; Rating::delete(db, self, team).await?;
@ -215,10 +210,7 @@ impl Station {
let waiting_teams: Vec<&Team> = teams.waiting.iter().map(|(team, _)| team).collect(); let waiting_teams: Vec<&Team> = teams.waiting.iter().map(|(team, _)| team).collect();
if !waiting_teams.contains(&team) { if !waiting_teams.contains(&team) {
return Err(format!( return Err(t!("team_cant_start_not_in_waiting", team = team.name).into());
"Team kann nicht starten, weil das Team {} nicht in der Warteschlange ist.",
team.name
));
} }
sqlx::query!( sqlx::query!(
@ -243,10 +235,11 @@ impl Station {
let doing_teams: Vec<&Team> = teams.doing.iter().map(|(team, _)| team).collect(); let doing_teams: Vec<&Team> = teams.doing.iter().map(|(team, _)| team).collect();
if !doing_teams.contains(&team) { if !doing_teams.contains(&team) {
return Err(format!( return Err(t!(
"Team kann nicht zur Warteschlange hinzugefügt werden, weil das Team {} aktuell nicht an deiner Station arbeitet.", "team_removal_active_not_possible_not_there",
team.name team = team.name
)); )
.into());
} }
sqlx::query!( sqlx::query!(
@ -267,10 +260,7 @@ impl Station {
let doing_teams: Vec<&Team> = teams.doing.iter().map(|(team, _)| team).collect(); let doing_teams: Vec<&Team> = teams.doing.iter().map(|(team, _)| team).collect();
if !doing_teams.contains(&team) { if !doing_teams.contains(&team) {
return Err(format!( return Err(t!("team_cant_finish_not_in_active", team = team.name).into());
"Team kann nicht beenden, weil das Team {} nicht an der Station arbeitet.",
team.name
));
} }
sqlx::query!( sqlx::query!(
@ -301,10 +291,7 @@ impl Station {
.collect(); .collect();
if !left_and_rated_teams.contains(&team) && !left_not_yet_rated_teams.contains(&team) { if !left_and_rated_teams.contains(&team) && !left_not_yet_rated_teams.contains(&team) {
return Err(format!( return Err(t!("team_removal_left_not_possible_not_there", team = team.name).into());
"Team kann nicht zur Arbeitsposition hinzugefügt werden, weil das Team {} aktuell nicht feritg ist",
team.name
));
} }
sqlx::query!( sqlx::query!(

View File

@ -1,14 +1,14 @@
use crate::{ use crate::{
AppState, Station, admin::team::Team, err, models::rating::TeamsAtStationLocation, partials, admin::team::Team, er, err, models::rating::TeamsAtStationLocation, partials, suc, AppState,
succ, Station,
}; };
use axum::{ use axum::{
Form, Router,
extract::State, extract::State,
response::{IntoResponse, Redirect}, response::{IntoResponse, Redirect},
routing::{get, post}, routing::{get, post},
Form, Router,
}; };
use maud::{Markup, PreEscaped, html}; use maud::{html, Markup, PreEscaped};
use serde::Deserialize; use serde::Deserialize;
use sqlx::SqlitePool; use sqlx::SqlitePool;
use std::sync::Arc; use std::sync::Arc;
@ -22,7 +22,7 @@ async fn view(
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
let content = html! { let content = html! {
article class="error" { article class="error" {
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben." (t!("invalid_rating_code"))
} }
}; };
return partials::page(content, session, false).await; return partials::page(content, session, false).await;
@ -32,18 +32,28 @@ async fn view(
let teams_on_the_way = station.teams_on_the_way(&db).await; let teams_on_the_way = station.teams_on_the_way(&db).await;
let content = html! { let content = html! {
h1 { (format!("Station {}", station.name)) } h1 {
(t!("station"))
" "
(station.name)
}
@if let (Some(lat), Some(lng)) = (station.lat, station.lng) { @if let (Some(lat), Some(lng)) = (station.lat, station.lng) {
article { article {
details open[(!station.ready)]{ details open[(!station.ready)]{
summary { "Infos" } summary { (t!("infos")) }
@let first_teams = Team::all_with_first_station(&db, &station).await; @let first_teams = Team::all_with_first_station(&db, &station).await;
@if first_teams.is_empty() { @if first_teams.is_empty() {
div { div {
"Du musst keine Teams zu deiner Station mitnehmen" (t!("station_has_no_teams_to_take_to_start"))
} }
} @else{ } @else{
b { (format!("Nimm bitte folgende {} Teams am Anfang zu deiner Station mit:", first_teams.len())) } b {
@if first_teams.len() == 1 {
(t!("station_should_take_one_teams_to_start"))
} @else {
(t!("station_should_take_n_teams_to_start", amount=first_teams.len()))
}
}
ol { ol {
@for team in first_teams { @for team in first_teams {
li { li {
@ -54,7 +64,12 @@ async fn view(
@if let Some(amount_people) = team.amount_people { @if let Some(amount_people) = team.amount_people {
li { li {
(amount_people) (amount_people)
" Personen" " "
@if amount_people == 1 {
(t!("person"))
} @else {
(t!("people"))
}
} }
} }
@if let Some(notes) = team.notes { @if let Some(notes) = team.notes {
@ -68,7 +83,7 @@ async fn view(
} }
} }
} }
b { "Hier befindet sich deine Station:" } b { (t!("your_station_is_here")) }
div id="map" style="height: 500px" {} div id="map" style="height: 500px" {}
script { (format!(" script { (format!("
const map = L.map('map').setView([{lat}, {lng}], 14); const map = L.map('map').setView([{lat}, {lng}], 14);
@ -96,63 +111,61 @@ async fn view(
hr; hr;
a href=(format!("/s/{id}/{code}/ready")){ a href=(format!("/s/{id}/{code}/ready")){
@if station.ready { @if station.ready {
"Bin mit der Station doch noch nicht bereit..." (t!("station_not_yet_ready"))
} @else { } @else {
button { "Ich bin bei meiner Station und bin bereit zu starten!" } button { (t!("station_ready")) }
} }
} }
} }
} }
} }
article { article {
"Insgesamt sollten " @if teams.total_teams == 1 {
(teams.total_teams) (t!("one_team_should_come_to_station"))
" Teams zu deiner Station kommen." } @else{
(t!("n_teams_should_come_to_station", amount=teams.total_teams))
}
progress value=(teams.total_teams-teams.not_yet_here.len() as i64) max=(teams.total_teams) {} progress value=(teams.total_teams-teams.not_yet_here.len() as i64) max=(teams.total_teams) {}
} }
@for team in teams_on_the_way { @for team in teams_on_the_way {
article { article {
"Team " (t!("team_on_the_way_to_your_station", team=team.team.name, time=team.left))
(team.team.name)
" ist seit "
(team.left)
" auf dem Weg zu deiner Station."
form action=(format!("/s/{id}/{code}/new-waiting")) method="post" { form action=(format!("/s/{id}/{code}/new-waiting")) method="post" {
input type="hidden" name="team_id" value=(team.team.id); input type="hidden" name="team_id" value=(team.team.id);
input type="submit" value="Team ist da"; input type="submit" value=(t!("team_is_here"));
} }
} }
} }
@if !teams.not_yet_here.is_empty() { @if !teams.not_yet_here.is_empty() {
form action=(format!("/s/{id}/{code}/new-waiting")) method="post" { form action=(format!("/s/{id}/{code}/new-waiting")) method="post" {
fieldset role="group" { fieldset role="group" {
select name="team_id" aria-label="Team auswählen" required { select name="team_id" aria-label=(t!("select_team")) required {
@for team in &teams.not_yet_here { @for team in &teams.not_yet_here {
option value=(team.id) { option value=(team.id) {
(team.name) (team.name)
} }
} }
} }
input type="submit" value="Neues Team da"; input type="submit" value=(t!("team_is_here"));
} }
} }
} }
h2 { "Teams bei dir" } h2 { (t!("teams_at_your_station")) }
@if !teams.doing.is_empty() { @if !teams.doing.is_empty() {
@for (team, rating) in teams.doing { @for (team, rating) in teams.doing {
article { article {
details { details {
summary { summary {
em data-tooltip="Aktiv" { "🎬 " } em data-tooltip=(t!("state_active")) { (t!("state_active_icon")) }
(team.name) (team.name)
small { small {
" (seit " " ("
(rating.local_time_doing()) (t!("since_time", time=rating.local_time_doing()))
")" ")"
} }
"✏️" "✏️"
a href=(format!("/s/{id}/{code}/team-finished/{}", team.id)) { a href=(format!("/s/{id}/{code}/team-finished/{}", team.id)) {
button { "Team fertig" } button { (t!("team_finished")) }
} }
} }
form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" { form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" {
@ -164,10 +177,10 @@ async fn view(
input type="text" name="notes"; input type="text" name="notes";
} }
} }
input type="submit" value="Notizen speichern"; input type="submit" value=(t!("save_notes"));
} }
a href=(format!("/s/{id}/{code}/remove-doing/{}", team.id)) a href=(format!("/s/{id}/{code}/remove-doing/{}", team.id))
onclick="return confirm('Bist du sicher, dass das Team noch nicht bei dir arbeitet? Das Team wird zurück auf die Warte-Position gesetzt');" { onclick=(format!("return confirm('{}');", t!("confirm_station_cancel_team_active", team=team.name))) {
"🗑️" "🗑️"
} }
} }
@ -179,16 +192,16 @@ async fn view(
article { article {
details { details {
summary { summary {
em data-tooltip="Wartend" { "" } em data-tooltip=(t!("state_waiting")) { (t!("state_waiting_icon"))}
(team.name) (team.name)
small { small {
" (seit " " ("
(rating.local_time_arrived_at()) (t!("since_time", time=rating.local_time_arrived_at()))
")" ")"
} }
"✏️" "✏️"
a href=(format!("/s/{id}/{code}/team-starting/{}", team.id)) { a href=(format!("/s/{id}/{code}/team-starting/{}", team.id)) {
button { "Team startet" } button { (t!("team_starting")) }
} }
} }
form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" { form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" {
@ -200,10 +213,10 @@ async fn view(
input type="text" name="notes"; input type="text" name="notes";
} }
} }
input type="submit" value="Notizen speichern"; input type="submit" value=(t!("save_notes"));
} }
a href=(format!("/s/{id}/{code}/remove-waiting/{}", team.id)) a href=(format!("/s/{id}/{code}/remove-waiting/{}", team.id))
onclick="return confirm('Bist du sicher, dass das Team noch nicht bei dir ist? Das kann _NICHT_ mehr rückgängig gemacht werden.');" { onclick=(format!("return confirm('{}');", t!("confirm_station_cancel_team_waiting", team=team.name))) {
"🗑️" "🗑️"
} }
} }
@ -211,44 +224,48 @@ async fn view(
} }
} }
@if !teams.left_not_yet_rated.is_empty() { @if !teams.left_not_yet_rated.is_empty() {
h2 { "Noch zu bewerten" } h2 { (t!("to_rate")) }
article class="warning" { article class="warning" {
"Noch keine Punkte für diese Gruppe vergeben ⤵️" @if teams.left_not_yet_rated.len() == 1 {
(t!("info_single_team_not_yet_rated"))
} @else {
(t!("info_multiple_teams_not_yet_rated"))
}
} }
@for (team, rating) in teams.left_not_yet_rated { @for (team, rating) in teams.left_not_yet_rated {
article { article {
em data-tooltip="Zu bewerten" { "" } em data-tooltip=(t!("state_to_rate")) { (t!("state_to_rate_icon")) }
(team.name) (team.name)
small { small {
" (um " " ("
(rating.local_time_left()) (t!("left_at", time=rating.local_time_left()))
" gegangen)" ")"
} }
form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" { form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" {
label { label {
@if let Some(points) = rating.points { @if let Some(points) = rating.points {
span { (points) " Punkte" } span { (points) " " (t!("points")) }
input type="range" name="points" min="0" max="10" value=(points) input type="range" name="points" min="0" max="10" value=(points)
onchange="if(!confirm('Du hast die Gruppe bereits bewertet. Bist du sicher, dass du deine Bewertung nochmal ändern möchtest?')) { this.value = this.defaultValue; this.previousElementSibling.textContent = this.defaultValue + ' Punkte'; }" onchange=(format!("if(!confirm('{}')) {{ this.value = this.defaultValue; this.previousElementSibling.textContent = this.defaultValue + ' Punkte'; }}", t!("confirm_rating_change")))
oninput="this.previousElementSibling.textContent = this.value + ' Punkte'" {} oninput=(format!("this.previousElementSibling.textContent = this.value + ' {}'", t!("points"))) {}
} @else { } @else {
span { "0 Punkte" } span { "0 " (t!("points")) }
input type="range" name="points" min="0" max="10" value="0" oninput="this.previousElementSibling.textContent = this.value + ' Punkte'" {} input type="range" name="points" min="0" max="10" value="0" oninput="this.previousElementSibling.textContent = this.value + ' Punkte'" {}
} }
} }
label { label {
"Notizen" (t!("notes"))
@if let Some(notes) = &rating.notes { @if let Some(notes) = &rating.notes {
input type="text" name="notes" value=(notes); input type="text" name="notes" value=(notes);
} @else { } @else {
input type="text" name="notes"; input type="text" name="notes";
} }
} }
input type="submit" value="Speichern"; input type="submit" value=(t!("save_notes"));
} }
a href=(format!("/s/{id}/{code}/remove-left/{}", team.id)) a href=(format!("/s/{id}/{code}/remove-left/{}", team.id))
onclick="return confirm('Bist du sicher, dass das Team noch nicht bei dir fertig ist? Das Team wird zurück auf die Arbeits-Position gesetzt');" { onclick=(format!("return confirm('{}');", t!("confirm_station_cancel_team_finished"))) {
"🗑️" "🗑️"
} }
} }
@ -256,56 +273,53 @@ async fn view(
} }
h2 { "Was bisher geschah" } h2 { (t!("history")) }
@if !teams.left_and_rated.is_empty() { @if !teams.left_and_rated.is_empty() {
@for (team, rating) in teams.left_and_rated { @for (team, rating) in teams.left_and_rated {
article { article {
details { details {
summary { summary {
em data-tooltip="Schon bewertet" { "" } em data-tooltip=(t!("state_rated")) { (t!("state_rated_icon")) }
(team.name) (team.name)
(PreEscaped(" &rarr; ")) (PreEscaped(" &rarr; "))
(rating.points.unwrap()) (rating.points.unwrap())
" Punkte" " "
(t!("points"))
} }
small { small {
" (um " " ("
(rating.local_time_arrived_at()) (t!("arrived_at_started_at_left_at", arrived=rating.local_time_arrived_at(), active=rating.local_time_doing(), left=rating.local_time_left()))
" eingetroffen, um " ")"
(rating.local_time_doing())
" gestartet und um "
(rating.local_time_left())
" gegangen)"
} }
form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" { form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" {
label { label {
@if let Some(points) = rating.points { @if let Some(points) = rating.points {
span { (points) " Punkte" } span { (points) " Punkte" }
input type="range" name="points" min="0" max="10" value=(points) input type="range" name="points" min="0" max="10" value=(points)
onchange="if(!confirm('Du hast die Gruppe bereits bewertet. Bist du sicher, dass du deine Bewertung nochmal ändern möchtest?')) { this.value = this.defaultValue; this.previousElementSibling.textContent = this.defaultValue + ' Punkte'; }" onchange=(format!("if(!confirm('{}')) {{ this.value = this.defaultValue; this.previousElementSibling.textContent = this.defaultValue + ' Punkte'; }}", t!("confirm_rating_change")))
oninput="this.previousElementSibling.textContent = this.value + ' Punkte'" {} oninput=(format!("this.previousElementSibling.textContent = this.value + ' {}'", t!("points"))) {}
} }
} }
label { label {
"Notizen" (t!("notes"))
@if let Some(notes) = &rating.notes { @if let Some(notes) = &rating.notes {
input type="text" name="notes" value=(notes); input type="text" name="notes" value=(notes);
} @else { } @else {
input type="text" name="notes"; input type="text" name="notes";
} }
} }
input type="submit" value="Speichern"; input type="submit" value=(t!("save_notes"));
} }
a href=(format!("/s/{id}/{code}/remove-left/{}", team.id)) a href=(format!("/s/{id}/{code}/remove-left/{}", team.id))
onclick="return confirm('Bist du sicher, dass das Team noch nicht bei dir fertig ist? Das Team wird zurück auf die Arbeits-Position gesetzt');" { onclick=(format!("return confirm('{}');", t!("confirm_station_cancel_team_finished"))) {
"🗑️" "🗑️"
} }
} }
} }
} }
} @else { } @else {
"Du hast bisher noch keine Teams bewertet." (t!("no_teams_rated_yet"))
} }
}; };
@ -321,16 +335,13 @@ async fn ready(
axum::extract::Path((id, code)): axum::extract::Path<(i64, String)>, axum::extract::Path((id, code)): axum::extract::Path<(i64, String)>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
station.switch_ready(&db).await; station.switch_ready(&db).await;
succ!(session, "Erfolgreich geändert"); suc!(session, t!("succ_change"));
Redirect::to(&format!("/s/{id}/{code}")) Redirect::to(&format!("/s/{id}/{code}"))
} }
@ -345,23 +356,19 @@ async fn new_waiting(
Form(form): Form<NewWaitingForm>, Form(form): Form<NewWaitingForm>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
let Some(team) = Team::find_by_id(&db, form.team_id).await else { let Some(team) = Team::find_by_id(&db, form.team_id).await else {
err!( er!(
session, session,
"Konnte das Team der Warteschlange nicht hinzufügen, weil ein Team mit ID {} nicht existiert", t!("cant_add_nonexisting_team_to_waiting", id = form.team_id)
form.team_id
); );
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
match station.new_team_waiting(&db, &team).await { match station.new_team_waiting(&db, &team).await {
Ok(()) => succ!(session, "Team der Warteschlange hinzugefügt"), Ok(()) => suc!(session, t!("team_added_to_waiting", team = team.name)),
Err(e) => err!(session, "{e}"), Err(e) => err!(session, "{e}"),
} }
@ -374,24 +381,20 @@ async fn remove_waiting(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>, axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
let Some(team) = Team::find_by_id(&db, team_id).await else { let Some(team) = Team::find_by_id(&db, team_id).await else {
err!( er!(
session, session,
"Konnte das Team nicht von der Warteschlange entfernen, weil ein Team mit ID {} nicht existiert", t!("cant_remove_nonexisting_team_from_waiting", id = team_id)
team_id
); );
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
match station.remove_team_waiting(&db, &team).await { match station.remove_team_waiting(&db, &team).await {
Ok(()) => succ!(session, "Team der Warteschlange gelöscht"), Ok(()) => suc!(session, t!("team_removed_from_waiting", team = team.name)),
Err(e) => err!(session, "{e}"), Err(e) => err!(session, "{e}"),
} }
@ -404,24 +407,20 @@ async fn team_starting(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>, axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
let Some(team) = Team::find_by_id(&db, team_id).await else { let Some(team) = Team::find_by_id(&db, team_id).await else {
err!( er!(
session, session,
"Team kann nicht starten, weil ein Team mit ID {} nicht existiert", t!("cant_add_nonexisting_team_to_active", id = team_id)
team_id
); );
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
match station.team_starting(&db, &team).await { match station.team_starting(&db, &team).await {
Ok(()) => succ!(session, "Team der Warteschlange gelöscht"), Ok(()) => suc!(session, t!("team_added_to_active", team = team.name)),
Err(e) => err!(session, "{e}"), Err(e) => err!(session, "{e}"),
} }
@ -434,24 +433,20 @@ async fn remove_doing(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>, axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
let Some(team) = Team::find_by_id(&db, team_id).await else { let Some(team) = Team::find_by_id(&db, team_id).await else {
err!( er!(
session, session,
"Konnte das Team nicht zur Warteschlange hinzufügen, weil ein Team mit ID {} nicht existiert", t!("cant_remove_nonexisting_team_from_active", id = team_id)
team_id
); );
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
match station.remove_team_doing(&db, &team).await { match station.remove_team_doing(&db, &team).await {
Ok(()) => succ!(session, "Team zur Warteschlange hinzugefügt"), Ok(()) => suc!(session, t!("team_removed_from_active", team = team.name)),
Err(e) => err!(session, "{e}"), Err(e) => err!(session, "{e}"),
} }
@ -464,24 +459,20 @@ async fn team_finished(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>, axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
let Some(team) = Team::find_by_id(&db, team_id).await else { let Some(team) = Team::find_by_id(&db, team_id).await else {
err!( er!(
session, session,
"Team kann nicht beenden, weil ein Team mit ID {} nicht existiert", t!("cant_add_nonexisting_team_to_finished", id = team_id)
team_id
); );
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
match station.team_finished(&db, &team).await { match station.team_finished(&db, &team).await {
Ok(()) => succ!(session, "Team erfolgreich beendet"), Ok(()) => suc!(session, t!("team_added_to_finished")),
Err(e) => err!(session, "{e}"), Err(e) => err!(session, "{e}"),
} }
@ -494,24 +485,20 @@ async fn remove_left(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>, axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
let Some(team) = Team::find_by_id(&db, team_id).await else { let Some(team) = Team::find_by_id(&db, team_id).await else {
err!( er!(
session, session,
"Konnte das Team nicht zur Arbeits-Position hinzufügen, weil ein Team mit ID {} nicht existiert", t!("cant_remove_nonexisting_team_from_finished", id = team_id)
team_id
); );
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
match station.remove_team_left(&db, &team).await { match station.remove_team_left(&db, &team).await {
Ok(()) => succ!(session, "Team zur Arbeitsposition hinzugefügt"), Ok(()) => suc!(session, t!("team_removed_from_finished")),
Err(e) => err!(session, "{e}"), Err(e) => err!(session, "{e}"),
} }
@ -530,18 +517,11 @@ async fn team_update(
Form(form): Form<TeamUpdateForm>, Form(form): Form<TeamUpdateForm>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else { let Some(station) = Station::login(&db, id, &code).await else {
err!( er!(session, t!("invalid_rating_code"));
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
let Some(team) = Team::find_by_id(&db, team_id).await else { let Some(team) = Team::find_by_id(&db, team_id).await else {
err!( er!(session, t!("cant_update_nonexisting_team", id = team_id));
session,
"Konnte das Team nicht updaten, weil ein Team mit ID {} nicht existiert",
team_id
);
return Redirect::to("/s/{id}/{code}"); return Redirect::to("/s/{id}/{code}");
}; };
@ -549,7 +529,7 @@ async fn team_update(
.team_update(&db, &team, form.points, form.notes) .team_update(&db, &team, form.points, form.notes)
.await .await
{ {
Ok(()) => succ!(session, "Team bearbeitet"), Ok(()) => suc!(session, t!("rating_updated", team = team.name)),
Err(e) => err!(session, "{e}"), Err(e) => err!(session, "{e}"),
} }
@ -571,7 +551,7 @@ pub(super) fn routes() -> Router<AppState> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::{Station, router, testdb}; use crate::{router, testdb, Station};
use sqlx::SqlitePool; use sqlx::SqlitePool;
@ -587,9 +567,7 @@ mod test {
let response = server.get("/s/1/wrong-pw").await; let response = server.get("/s/1/wrong-pw").await;
response.assert_text_contains( response.assert_text_contains(t!("invalid_rating_code"));
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben.",
);
} }
#[sqlx::test] #[sqlx::test]