Compare commits

...

2 Commits

Author SHA1 Message Date
6b07772a18 format
All checks were successful
CI/CD Pipeline / test (push) Successful in 5m20s
CI/CD Pipeline / deploy (push) Successful in 3m56s
2025-04-21 15:14:52 +02:00
d57fd670b3 cargo clippy 2025-04-21 15:14:42 +02:00
15 changed files with 58 additions and 57 deletions

View File

@@ -1,7 +1,7 @@
use crate::{auth::Backend, models::rating::Rating, page, AppState};
use axum::{extract::State, routing::get, Router};
use crate::{AppState, auth::Backend, models::rating::Rating, page};
use axum::{Router, extract::State, routing::get};
use axum_login::login_required;
use maud::{html, Markup};
use maud::{Markup, html};
use rand::{
distr::{Distribution, Uniform},
rng,

View File

@@ -1,6 +1,6 @@
use crate::{
admin::{station::Station, team::Team},
AppState,
admin::{station::Station, team::Team},
};
use axum::Router;
use futures::future::join_all;
@@ -154,7 +154,7 @@ DROP TABLE temp_pos;",
self.stations(db)
.await
.into_iter()
.filter(|s| s.crewless())
.filter(Station::crewless)
.collect()
}

View File

@@ -1,12 +1,12 @@
use super::Route;
use crate::{admin::station::Station, er, page, suc, AppState};
use crate::{AppState, admin::station::Station, er, page, suc};
use axum::{
Form, Router,
extract::State,
response::{IntoResponse, Redirect},
routing::{get, post},
Form, Router,
};
use maud::{html, Markup, PreEscaped};
use maud::{Markup, PreEscaped, html};
use serde::Deserialize;
use sqlx::SqlitePool;
use std::sync::Arc;

View File

@@ -1,13 +1,13 @@
use super::{generate_random_alphanumeric, team::Team};
use crate::{
AppState,
admin::route::Route,
models::rating::{Rating, TeamsAtStationLocation},
AppState,
};
use axum::Router;
use chrono::{DateTime, Local, NaiveDateTime, Utc};
use futures::{stream, StreamExt};
use maud::{html, Markup, Render};
use futures::{StreamExt, stream};
use maud::{Markup, Render, html};
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};
@@ -450,10 +450,10 @@ AND r.left_at IS NOT NULL;",
let missing_teams: Vec<Team> = stream::iter(teams)
.filter_map(|entry| async move {
if !entry.been_at_station(db, &self).await {
Some(entry)
} else {
if entry.been_at_station(db, self).await {
None
} else {
Some(entry)
}
})
.collect()

View File

@@ -1,17 +1,18 @@
use crate::{
AppState,
admin::{station::Station, team::Team},
er, err,
models::rating::{Rating, TeamsAtStationLocation},
partials::page,
suc, succ, AppState,
suc, succ,
};
use axum::{
Form, Router,
extract::State,
response::{IntoResponse, Redirect},
routing::{get, post},
Form, Router,
};
use maud::{html, Markup};
use maud::{Markup, html};
use serde::Deserialize;
use sqlx::SqlitePool;
use std::{collections::HashMap, sync::Arc};
@@ -525,7 +526,7 @@ async fn quick_post(
let mut ret = String::new();
let mut amount_succ = 0;
for (team_id, points) in form.fields.iter() {
for (team_id, points) in &form.fields {
let Ok(team_id) = team_id.parse::<i64>() else {
ret.push_str(&format!(
"Skipped team_id={team_id} because this id can't be parsed as i64"

View File

@@ -1,7 +1,7 @@
use crate::{
AppState,
admin::{route::Route, station::Station},
models::rating::Rating,
AppState,
};
use axum::Router;
use chrono::{DateTime, Local, NaiveDateTime, Utc};
@@ -230,7 +230,7 @@ impl Team {
}
pub async fn been_at_station(&self, db: &SqlitePool, station: &Station) -> bool {
Rating::find_by_team_and_station(db, &self, station)
Rating::find_by_team_and_station(db, self, station)
.await
.is_some()
}

View File

@@ -1,18 +1,19 @@
use super::{CreateError, LastContactTeam, Team};
use crate::{
AppState,
admin::{route::Route, station::Station},
err,
models::rating::Rating,
partials::page,
pl, succ, AppState,
pl, succ,
};
use axum::{
Form, Router,
extract::State,
response::{IntoResponse, Redirect},
routing::{get, post},
Form, Router,
};
use maud::{html, Markup, PreEscaped};
use maud::{Markup, PreEscaped, html};
use serde::Deserialize;
use sqlx::SqlitePool;
use std::{collections::HashMap, sync::Arc};
@@ -47,26 +48,26 @@ async fn create(
}
Err(CreateError::DuplicateName(e)) => {
err!(
session,
"Team '{}' konnte _NICHT_ erstellt werden, da es bereits ein Team mit diesem Namen gibt ({e})!",
form.name
);
session,
"Team '{}' konnte _NICHT_ erstellt werden, da es bereits ein Team mit diesem Namen gibt ({e})!",
form.name
);
return Redirect::to("/admin/team");
}
Err(CreateError::NoStationForRoute) => {
err!(
session,
"Team '{}' konnte _NICHT_ erstellt werden, da in der angegebenen Route '{}' noch keine Stationen vorkommen",
form.name,
route.name
);
session,
"Team '{}' konnte _NICHT_ erstellt werden, da in der angegebenen Route '{}' noch keine Stationen vorkommen",
form.name,
route.name
);
return Redirect::to("/admin/team");
}
};
Redirect::to(&format!("/admin/team/{}", id))
Redirect::to(&format!("/admin/team/{id}"))
}
async fn delete(
@@ -119,7 +120,7 @@ async fn quick(db: Arc<SqlitePool>, team: &Team, stations: Vec<Station>, redirec
}
}
td {
@if let Some(rating) = Rating::find_by_team_and_station(&db, &team, station).await {
@if let Some(rating) = Rating::find_by_team_and_station(&db, team, station).await {
a href=(format!("/s/{}/{}", station.id, station.pw)){
@if let Some(points) = rating.points {
em data-tooltip="Schon eingetragen" {
@@ -208,7 +209,7 @@ async fn quick_post(
let mut ret = String::new();
let mut amount_succ = 0;
for (station_id, points) in form.fields.iter() {
for (station_id, points) in &form.fields {
let Ok(station_id) = station_id.parse::<i64>() else {
ret.push_str(&format!(
"Skipped stationid={station_id} because this id can't be parsed as i64"
@@ -217,8 +218,7 @@ async fn quick_post(
};
let Ok(points) = points.parse::<i64>() else {
ret.push_str(&format!(
"Skipped stationid={station_id} because points {} can't be parsed as i64",
points
"Skipped stationid={station_id} because points {points} can't be parsed as i64",
));
continue;
};

View File

@@ -1,7 +1,7 @@
use super::generate_random_alphanumeric;
use crate::{auth::User, AppState};
use crate::{AppState, auth::User};
use argon2::password_hash::rand_core::OsRng;
use argon2::{password_hash::SaltString, Argon2, PasswordHasher};
use argon2::{Argon2, PasswordHasher, password_hash::SaltString};
use axum::Router;
use sqlx::SqlitePool;

View File

@@ -1,11 +1,11 @@
use crate::{auth::User, err, partials::page, succ, AppState};
use crate::{AppState, auth::User, err, partials::page, succ};
use axum::{
Form, Router,
extract::State,
response::{IntoResponse, Redirect},
routing::{get, post},
Form, Router,
};
use maud::{html, Markup};
use maud::{Markup, html};
use serde::Deserialize;
use sqlx::SqlitePool;
use std::sync::Arc;
@@ -37,7 +37,7 @@ async fn create(
}
};
Redirect::to(&format!("/admin/user/{}", id))
Redirect::to(&format!("/admin/user/{id}"))
}
async fn delete(

View File

@@ -1,13 +1,13 @@
use crate::{er, page, suc, AppState};
use crate::{AppState, er, page, suc};
use async_trait::async_trait;
use axum::{
Form, Router,
http::StatusCode,
response::{IntoResponse, Redirect},
routing::{get, post},
Form, Router,
};
use axum_login::{AuthUser, AuthnBackend};
use maud::{html, Markup};
use maud::{Markup, html};
use password_auth::verify_password;
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};

View File

@@ -19,20 +19,20 @@ i18n!("locales", fallback = "de-AT");
use admin::station::Station;
use auth::{AuthSession, Backend, User};
use axum::{
Form, Router,
body::Body,
extract::{FromRef, State},
response::{IntoResponse, Redirect, Response},
routing::{get, post},
Form, Router,
};
use axum_login::AuthManagerLayerBuilder;
use maud::{html, Markup};
use maud::{Markup, html};
use partials::page;
use serde::Deserialize;
use sqlx::SqlitePool;
use std::{env, sync::Arc};
use tokio::net::TcpListener;
use tower_sessions::{cookie::time::Duration, Expiry, Session, SessionManagerLayer};
use tower_sessions::{Expiry, Session, SessionManagerLayer, cookie::time::Duration};
use tower_sessions_sqlx_store_chrono::SqliteStore;
pub(crate) mod admin;

View File

@@ -1,5 +1,5 @@
use dotenv::dotenv;
use sqlx::{pool::PoolOptions, SqlitePool};
use sqlx::{SqlitePool, pool::PoolOptions};
use std::env;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

View File

@@ -1,4 +1,4 @@
use crate::{admin::team::Team, Station};
use crate::{Station, admin::team::Team};
use chrono::{DateTime, Local, NaiveDateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, SqlitePool};

View File

@@ -1,5 +1,5 @@
use crate::test_version;
use maud::{html, Markup, DOCTYPE};
use maud::{DOCTYPE, Markup, html};
use tower_sessions::Session;
pub(crate) async fn page(content: Markup, session: Session, leaflet: bool) -> Markup {

View File

@@ -1,14 +1,14 @@
use crate::{
admin::team::Team, err, models::rating::TeamsAtStationLocation, partials, succ, AppState,
Station,
AppState, Station, admin::team::Team, err, models::rating::TeamsAtStationLocation, partials,
succ,
};
use axum::{
Form, Router,
extract::State,
response::{IntoResponse, Redirect},
routing::{get, post},
Form, Router,
};
use maud::{html, Markup, PreEscaped};
use maud::{Markup, PreEscaped, html};
use serde::Deserialize;
use sqlx::SqlitePool;
use std::sync::Arc;
@@ -571,7 +571,7 @@ pub(super) fn routes() -> Router<AppState> {
#[cfg(test)]
mod test {
use crate::{router, testdb, Station};
use crate::{Station, router, testdb};
use sqlx::SqlitePool;