Compare commits
2 Commits
4a0f6c0285
...
6b07772a18
Author | SHA1 | Date | |
---|---|---|---|
6b07772a18 | |||
d57fd670b3 |
@@ -1,7 +1,7 @@
|
|||||||
use crate::{auth::Backend, models::rating::Rating, page, AppState};
|
use crate::{AppState, auth::Backend, models::rating::Rating, page};
|
||||||
use axum::{extract::State, routing::get, Router};
|
use axum::{Router, extract::State, routing::get};
|
||||||
use axum_login::login_required;
|
use axum_login::login_required;
|
||||||
use maud::{html, Markup};
|
use maud::{Markup, html};
|
||||||
use rand::{
|
use rand::{
|
||||||
distr::{Distribution, Uniform},
|
distr::{Distribution, Uniform},
|
||||||
rng,
|
rng,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
admin::{station::Station, team::Team},
|
|
||||||
AppState,
|
AppState,
|
||||||
|
admin::{station::Station, team::Team},
|
||||||
};
|
};
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
@@ -154,7 +154,7 @@ DROP TABLE temp_pos;",
|
|||||||
self.stations(db)
|
self.stations(db)
|
||||||
.await
|
.await
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|s| s.crewless())
|
.filter(Station::crewless)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
use super::Route;
|
use super::Route;
|
||||||
use crate::{admin::station::Station, er, page, suc, AppState};
|
use crate::{AppState, admin::station::Station, er, page, suc};
|
||||||
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::{html, Markup, PreEscaped};
|
use maud::{Markup, PreEscaped, html};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
use super::{generate_random_alphanumeric, team::Team};
|
use super::{generate_random_alphanumeric, team::Team};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
AppState,
|
||||||
admin::route::Route,
|
admin::route::Route,
|
||||||
models::rating::{Rating, TeamsAtStationLocation},
|
models::rating::{Rating, TeamsAtStationLocation},
|
||||||
AppState,
|
|
||||||
};
|
};
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use chrono::{DateTime, Local, NaiveDateTime, Utc};
|
use chrono::{DateTime, Local, NaiveDateTime, Utc};
|
||||||
use futures::{stream, StreamExt};
|
use futures::{StreamExt, stream};
|
||||||
use maud::{html, Markup, Render};
|
use maud::{Markup, Render, html};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, SqlitePool};
|
use sqlx::{FromRow, SqlitePool};
|
||||||
|
|
||||||
@@ -450,10 +450,10 @@ AND r.left_at IS NOT NULL;",
|
|||||||
|
|
||||||
let missing_teams: Vec<Team> = stream::iter(teams)
|
let missing_teams: Vec<Team> = stream::iter(teams)
|
||||||
.filter_map(|entry| async move {
|
.filter_map(|entry| async move {
|
||||||
if !entry.been_at_station(db, &self).await {
|
if entry.been_at_station(db, self).await {
|
||||||
Some(entry)
|
|
||||||
} else {
|
|
||||||
None
|
None
|
||||||
|
} else {
|
||||||
|
Some(entry)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@@ -1,17 +1,18 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
AppState,
|
||||||
admin::{station::Station, team::Team},
|
admin::{station::Station, team::Team},
|
||||||
er, err,
|
er, err,
|
||||||
models::rating::{Rating, TeamsAtStationLocation},
|
models::rating::{Rating, TeamsAtStationLocation},
|
||||||
partials::page,
|
partials::page,
|
||||||
suc, succ, AppState,
|
suc, succ,
|
||||||
};
|
};
|
||||||
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::{html, Markup};
|
use maud::{Markup, html};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
@@ -525,7 +526,7 @@ async fn quick_post(
|
|||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
let mut amount_succ = 0;
|
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 {
|
let Ok(team_id) = team_id.parse::<i64>() else {
|
||||||
ret.push_str(&format!(
|
ret.push_str(&format!(
|
||||||
"Skipped team_id={team_id} because this id can't be parsed as i64"
|
"Skipped team_id={team_id} because this id can't be parsed as i64"
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
AppState,
|
||||||
admin::{route::Route, station::Station},
|
admin::{route::Route, station::Station},
|
||||||
models::rating::Rating,
|
models::rating::Rating,
|
||||||
AppState,
|
|
||||||
};
|
};
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use chrono::{DateTime, Local, NaiveDateTime, Utc};
|
use chrono::{DateTime, Local, NaiveDateTime, Utc};
|
||||||
@@ -230,7 +230,7 @@ impl Team {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn been_at_station(&self, db: &SqlitePool, station: &Station) -> bool {
|
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
|
.await
|
||||||
.is_some()
|
.is_some()
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +1,19 @@
|
|||||||
use super::{CreateError, LastContactTeam, Team};
|
use super::{CreateError, LastContactTeam, Team};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
AppState,
|
||||||
admin::{route::Route, station::Station},
|
admin::{route::Route, station::Station},
|
||||||
err,
|
err,
|
||||||
models::rating::Rating,
|
models::rating::Rating,
|
||||||
partials::page,
|
partials::page,
|
||||||
pl, succ, AppState,
|
pl, succ,
|
||||||
};
|
};
|
||||||
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::{html, Markup, PreEscaped};
|
use maud::{Markup, PreEscaped, html};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
@@ -66,7 +67,7 @@ async fn create(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Redirect::to(&format!("/admin/team/{}", id))
|
Redirect::to(&format!("/admin/team/{id}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete(
|
async fn delete(
|
||||||
@@ -119,7 +120,7 @@ async fn quick(db: Arc<SqlitePool>, team: &Team, stations: Vec<Station>, redirec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
td {
|
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)){
|
a href=(format!("/s/{}/{}", station.id, station.pw)){
|
||||||
@if let Some(points) = rating.points {
|
@if let Some(points) = rating.points {
|
||||||
em data-tooltip="Schon eingetragen" {
|
em data-tooltip="Schon eingetragen" {
|
||||||
@@ -208,7 +209,7 @@ async fn quick_post(
|
|||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
let mut amount_succ = 0;
|
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 {
|
let Ok(station_id) = station_id.parse::<i64>() else {
|
||||||
ret.push_str(&format!(
|
ret.push_str(&format!(
|
||||||
"Skipped stationid={station_id} because this id can't be parsed as i64"
|
"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 {
|
let Ok(points) = points.parse::<i64>() else {
|
||||||
ret.push_str(&format!(
|
ret.push_str(&format!(
|
||||||
"Skipped stationid={station_id} because points {} can't be parsed as i64",
|
"Skipped stationid={station_id} because points {points} can't be parsed as i64",
|
||||||
points
|
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
use super::generate_random_alphanumeric;
|
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::rand_core::OsRng;
|
||||||
use argon2::{password_hash::SaltString, Argon2, PasswordHasher};
|
use argon2::{Argon2, PasswordHasher, password_hash::SaltString};
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
use crate::{auth::User, err, partials::page, succ, AppState};
|
use crate::{AppState, auth::User, err, partials::page, succ};
|
||||||
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::{html, Markup};
|
use maud::{Markup, html};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::sync::Arc;
|
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(
|
async fn delete(
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
use crate::{er, page, suc, AppState};
|
use crate::{AppState, er, page, suc};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use axum::{
|
use axum::{
|
||||||
|
Form, Router,
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
response::{IntoResponse, Redirect},
|
response::{IntoResponse, Redirect},
|
||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
Form, Router,
|
|
||||||
};
|
};
|
||||||
use axum_login::{AuthUser, AuthnBackend};
|
use axum_login::{AuthUser, AuthnBackend};
|
||||||
use maud::{html, Markup};
|
use maud::{Markup, html};
|
||||||
use password_auth::verify_password;
|
use password_auth::verify_password;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, SqlitePool};
|
use sqlx::{FromRow, SqlitePool};
|
||||||
|
@@ -19,20 +19,20 @@ i18n!("locales", fallback = "de-AT");
|
|||||||
use admin::station::Station;
|
use admin::station::Station;
|
||||||
use auth::{AuthSession, Backend, User};
|
use auth::{AuthSession, Backend, User};
|
||||||
use axum::{
|
use axum::{
|
||||||
|
Form, Router,
|
||||||
body::Body,
|
body::Body,
|
||||||
extract::{FromRef, State},
|
extract::{FromRef, State},
|
||||||
response::{IntoResponse, Redirect, Response},
|
response::{IntoResponse, Redirect, Response},
|
||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
Form, Router,
|
|
||||||
};
|
};
|
||||||
use axum_login::AuthManagerLayerBuilder;
|
use axum_login::AuthManagerLayerBuilder;
|
||||||
use maud::{html, Markup};
|
use maud::{Markup, html};
|
||||||
use partials::page;
|
use partials::page;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::{env, sync::Arc};
|
use std::{env, sync::Arc};
|
||||||
use tokio::net::TcpListener;
|
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;
|
use tower_sessions_sqlx_store_chrono::SqliteStore;
|
||||||
|
|
||||||
pub(crate) mod admin;
|
pub(crate) mod admin;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use sqlx::{pool::PoolOptions, SqlitePool};
|
use sqlx::{SqlitePool, pool::PoolOptions};
|
||||||
use std::env;
|
use std::env;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
use crate::{admin::team::Team, Station};
|
use crate::{Station, admin::team::Team};
|
||||||
use chrono::{DateTime, Local, NaiveDateTime, Utc};
|
use chrono::{DateTime, Local, NaiveDateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, SqlitePool};
|
use sqlx::{FromRow, SqlitePool};
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
use crate::test_version;
|
use crate::test_version;
|
||||||
use maud::{html, Markup, DOCTYPE};
|
use maud::{DOCTYPE, Markup, html};
|
||||||
use tower_sessions::Session;
|
use tower_sessions::Session;
|
||||||
|
|
||||||
pub(crate) async fn page(content: Markup, session: Session, leaflet: bool) -> Markup {
|
pub(crate) async fn page(content: Markup, session: Session, leaflet: bool) -> Markup {
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
admin::team::Team, err, models::rating::TeamsAtStationLocation, partials, succ, AppState,
|
AppState, Station, admin::team::Team, err, models::rating::TeamsAtStationLocation, partials,
|
||||||
Station,
|
succ,
|
||||||
};
|
};
|
||||||
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::{html, Markup, PreEscaped};
|
use maud::{Markup, PreEscaped, html};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -571,7 +571,7 @@ pub(super) fn routes() -> Router<AppState> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::{router, testdb, Station};
|
use crate::{Station, router, testdb};
|
||||||
|
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user