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"
login_succ: "Erfolgreich eingeloggt als %{name}"
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"
crewless_station: "Station ohne Stationsbetreuer"
station_create: "Station erstellen"
stations_expl_without_first_word: "sind festgelegte Orte mit spezifischen Aufgaben."
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"
teams: "Teams"
select_team: "Team auswählen"
go_to_teams: "Zu den Teams"
not_yet_started: "nocht nicht gestartet"
not_yet_done: "nocht nicht fertig"

View File

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

View File

@ -1,14 +1,14 @@
use crate::{
AppState, Station, admin::team::Team, err, models::rating::TeamsAtStationLocation, partials,
succ,
admin::team::Team, er, err, models::rating::TeamsAtStationLocation, partials, suc, AppState,
Station,
};
use axum::{
Form, Router,
extract::State,
response::{IntoResponse, Redirect},
routing::{get, post},
Form, Router,
};
use maud::{Markup, PreEscaped, html};
use maud::{html, Markup, PreEscaped};
use serde::Deserialize;
use sqlx::SqlitePool;
use std::sync::Arc;
@ -22,7 +22,7 @@ async fn view(
let Some(station) = Station::login(&db, id, &code).await else {
let content = html! {
article class="error" {
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
(t!("invalid_rating_code"))
}
};
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 content = html! {
h1 { (format!("Station {}", station.name)) }
h1 {
(t!("station"))
" "
(station.name)
}
@if let (Some(lat), Some(lng)) = (station.lat, station.lng) {
article {
details open[(!station.ready)]{
summary { "Infos" }
summary { (t!("infos")) }
@let first_teams = Team::all_with_first_station(&db, &station).await;
@if first_teams.is_empty() {
div {
"Du musst keine Teams zu deiner Station mitnehmen"
(t!("station_has_no_teams_to_take_to_start"))
}
} @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 {
@for team in first_teams {
li {
@ -54,7 +64,12 @@ async fn view(
@if let Some(amount_people) = team.amount_people {
li {
(amount_people)
" Personen"
" "
@if amount_people == 1 {
(t!("person"))
} @else {
(t!("people"))
}
}
}
@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" {}
script { (format!("
const map = L.map('map').setView([{lat}, {lng}], 14);
@ -96,63 +111,61 @@ async fn view(
hr;
a href=(format!("/s/{id}/{code}/ready")){
@if station.ready {
"Bin mit der Station doch noch nicht bereit..."
(t!("station_not_yet_ready"))
} @else {
button { "Ich bin bei meiner Station und bin bereit zu starten!" }
button { (t!("station_ready")) }
}
}
}
}
}
article {
"Insgesamt sollten "
(teams.total_teams)
" Teams zu deiner Station kommen."
@if teams.total_teams == 1 {
(t!("one_team_should_come_to_station"))
} @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) {}
}
@for team in teams_on_the_way {
article {
"Team "
(team.team.name)
" ist seit "
(team.left)
" auf dem Weg zu deiner Station."
(t!("team_on_the_way_to_your_station", team=team.team.name, time=team.left))
form action=(format!("/s/{id}/{code}/new-waiting")) method="post" {
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() {
form action=(format!("/s/{id}/{code}/new-waiting")) method="post" {
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 {
option value=(team.id) {
(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() {
@for (team, rating) in teams.doing {
article {
details {
summary {
em data-tooltip="Aktiv" { "🎬 " }
em data-tooltip=(t!("state_active")) { (t!("state_active_icon")) }
(team.name)
small {
" (seit "
(rating.local_time_doing())
" ("
(t!("since_time", time=rating.local_time_doing()))
")"
}
"✏️"
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" {
@ -164,10 +177,10 @@ async fn view(
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))
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 {
details {
summary {
em data-tooltip="Wartend" { "" }
em data-tooltip=(t!("state_waiting")) { (t!("state_waiting_icon"))}
(team.name)
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)) {
button { "Team startet" }
button { (t!("team_starting")) }
}
}
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="submit" value="Notizen speichern";
input type="submit" value=(t!("save_notes"));
}
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() {
h2 { "Noch zu bewerten" }
h2 { (t!("to_rate")) }
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 {
article {
em data-tooltip="Zu bewerten" { "" }
em data-tooltip=(t!("state_to_rate")) { (t!("state_to_rate_icon")) }
(team.name)
small {
" (um "
(rating.local_time_left())
" gegangen)"
" ("
(t!("left_at", time=rating.local_time_left()))
")"
}
form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" {
label {
@if let Some(points) = rating.points {
span { (points) " Punkte" }
span { (points) " " (t!("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'; }"
oninput="this.previousElementSibling.textContent = this.value + ' Punkte'" {}
onchange=(format!("if(!confirm('{}')) {{ this.value = this.defaultValue; this.previousElementSibling.textContent = this.defaultValue + ' Punkte'; }}", t!("confirm_rating_change")))
oninput=(format!("this.previousElementSibling.textContent = this.value + ' {}'", t!("points"))) {}
} @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'" {}
}
}
label {
"Notizen"
(t!("notes"))
@if let Some(notes) = &rating.notes {
input type="text" name="notes" value=(notes);
} @else {
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))
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() {
@for (team, rating) in teams.left_and_rated {
article {
details {
summary {
em data-tooltip="Schon bewertet" { "" }
em data-tooltip=(t!("state_rated")) { (t!("state_rated_icon")) }
(team.name)
(PreEscaped(" &rarr; "))
(rating.points.unwrap())
" Punkte"
" "
(t!("points"))
}
small {
" (um "
(rating.local_time_arrived_at())
" eingetroffen, um "
(rating.local_time_doing())
" gestartet und um "
(rating.local_time_left())
" gegangen)"
" ("
(t!("arrived_at_started_at_left_at", arrived=rating.local_time_arrived_at(), active=rating.local_time_doing(), left=rating.local_time_left()))
")"
}
form action=(format!("/s/{id}/{code}/team-update/{}", team.id)) method="post" {
label {
@if let Some(points) = rating.points {
span { (points) " Punkte" }
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'; }"
oninput="this.previousElementSibling.textContent = this.value + ' Punkte'" {}
onchange=(format!("if(!confirm('{}')) {{ this.value = this.defaultValue; this.previousElementSibling.textContent = this.defaultValue + ' Punkte'; }}", t!("confirm_rating_change")))
oninput=(format!("this.previousElementSibling.textContent = this.value + ' {}'", t!("points"))) {}
}
}
label {
"Notizen"
(t!("notes"))
@if let Some(notes) = &rating.notes {
input type="text" name="notes" value=(notes);
} @else {
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))
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 {
"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)>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
station.switch_ready(&db).await;
succ!(session, "Erfolgreich geändert");
suc!(session, t!("succ_change"));
Redirect::to(&format!("/s/{id}/{code}"))
}
@ -345,23 +356,19 @@ async fn new_waiting(
Form(form): Form<NewWaitingForm>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
let Some(team) = Team::find_by_id(&db, form.team_id).await else {
err!(
er!(
session,
"Konnte das Team der Warteschlange nicht hinzufügen, weil ein Team mit ID {} nicht existiert",
form.team_id
t!("cant_add_nonexisting_team_to_waiting", id = form.team_id)
);
return Redirect::to("/s/{id}/{code}");
};
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}"),
}
@ -374,24 +381,20 @@ async fn remove_waiting(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
let Some(team) = Team::find_by_id(&db, team_id).await else {
err!(
er!(
session,
"Konnte das Team nicht von der Warteschlange entfernen, weil ein Team mit ID {} nicht existiert",
team_id
t!("cant_remove_nonexisting_team_from_waiting", id = team_id)
);
return Redirect::to("/s/{id}/{code}");
};
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}"),
}
@ -404,24 +407,20 @@ async fn team_starting(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
let Some(team) = Team::find_by_id(&db, team_id).await else {
err!(
er!(
session,
"Team kann nicht starten, weil ein Team mit ID {} nicht existiert",
team_id
t!("cant_add_nonexisting_team_to_active", id = team_id)
);
return Redirect::to("/s/{id}/{code}");
};
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}"),
}
@ -434,24 +433,20 @@ async fn remove_doing(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
let Some(team) = Team::find_by_id(&db, team_id).await else {
err!(
er!(
session,
"Konnte das Team nicht zur Warteschlange hinzufügen, weil ein Team mit ID {} nicht existiert",
team_id
t!("cant_remove_nonexisting_team_from_active", id = team_id)
);
return Redirect::to("/s/{id}/{code}");
};
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}"),
}
@ -464,24 +459,20 @@ async fn team_finished(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
let Some(team) = Team::find_by_id(&db, team_id).await else {
err!(
er!(
session,
"Team kann nicht beenden, weil ein Team mit ID {} nicht existiert",
team_id
t!("cant_add_nonexisting_team_to_finished", id = team_id)
);
return Redirect::to("/s/{id}/{code}");
};
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}"),
}
@ -494,24 +485,20 @@ async fn remove_left(
axum::extract::Path((id, code, team_id)): axum::extract::Path<(i64, String, i64)>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
let Some(team) = Team::find_by_id(&db, team_id).await else {
err!(
er!(
session,
"Konnte das Team nicht zur Arbeits-Position hinzufügen, weil ein Team mit ID {} nicht existiert",
team_id
t!("cant_remove_nonexisting_team_from_finished", id = team_id)
);
return Redirect::to("/s/{id}/{code}");
};
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}"),
}
@ -530,18 +517,11 @@ async fn team_update(
Form(form): Form<TeamUpdateForm>,
) -> impl IntoResponse {
let Some(station) = Station::login(&db, id, &code).await else {
err!(
session,
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben."
);
er!(session, t!("invalid_rating_code"));
return Redirect::to("/s/{id}/{code}");
};
let Some(team) = Team::find_by_id(&db, team_id).await else {
err!(
session,
"Konnte das Team nicht updaten, weil ein Team mit ID {} nicht existiert",
team_id
);
er!(session, t!("cant_update_nonexisting_team", id = team_id));
return Redirect::to("/s/{id}/{code}");
};
@ -549,7 +529,7 @@ async fn team_update(
.team_update(&db, &team, form.points, form.notes)
.await
{
Ok(()) => succ!(session, "Team bearbeitet"),
Ok(()) => suc!(session, t!("rating_updated", team = team.name)),
Err(e) => err!(session, "{e}"),
}
@ -571,7 +551,7 @@ pub(super) fn routes() -> Router<AppState> {
#[cfg(test)]
mod test {
use crate::{Station, router, testdb};
use crate::{router, testdb, Station};
use sqlx::SqlitePool;
@ -587,9 +567,7 @@ mod test {
let response = server.get("/s/1/wrong-pw").await;
response.assert_text_contains(
"Falscher Quick-Einlogg-Link. Bitte nochmal scannen oder neu eingeben.",
);
response.assert_text_contains(t!("invalid_rating_code"));
}
#[sqlx::test]