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 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,
|
||||
|
@@ -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()
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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()
|
||||
|
@@ -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"
|
||||
|
@@ -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()
|
||||
}
|
||||
|
@@ -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};
|
||||
@@ -66,7 +67,7 @@ async fn create(
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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(
|
||||
|
@@ -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};
|
||||
|
@@ -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;
|
||||
|
@@ -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};
|
||||
|
||||
|
@@ -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};
|
||||
|
@@ -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 {
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user