allow admins to show logbook for any year
This commit is contained in:
parent
ae98a4278d
commit
58f8cb14b8
@ -260,6 +260,10 @@ ORDER BY departure DESC
|
|||||||
|
|
||||||
pub async fn completed(db: &SqlitePool) -> Vec<LogbookWithBoatAndRowers> {
|
pub async fn completed(db: &SqlitePool) -> Vec<LogbookWithBoatAndRowers> {
|
||||||
let year = chrono::Local::now().year();
|
let year = chrono::Local::now().year();
|
||||||
|
Self::completed_in_year(db, year).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn completed_in_year(db: &SqlitePool, year: i32) -> Vec<LogbookWithBoatAndRowers> {
|
||||||
let logs = sqlx::query_as(
|
let logs = sqlx::query_as(
|
||||||
&format!("
|
&format!("
|
||||||
SELECT id, boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
|
SELECT id, boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
|
||||||
|
@ -23,7 +23,7 @@ use crate::model::{
|
|||||||
LogbookUpdateError,
|
LogbookUpdateError,
|
||||||
},
|
},
|
||||||
logtype::LogType,
|
logtype::LogType,
|
||||||
user::{DonauLinzUser, User, UserWithRoles, UserWithWaterStatus},
|
user::{AdminUser, DonauLinzUser, User, UserWithRoles, UserWithWaterStatus},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct KioskCookie(String);
|
pub struct KioskCookie(String);
|
||||||
@ -96,6 +96,16 @@ async fn show(db: &State<SqlitePool>, user: DonauLinzUser) -> Template {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/show?<year>")]
|
||||||
|
async fn show_for_year(db: &State<SqlitePool>, user: AdminUser, year: i32) -> Template {
|
||||||
|
let logs = Logbook::completed_in_year(db, year).await;
|
||||||
|
|
||||||
|
Template::render(
|
||||||
|
"log.completed",
|
||||||
|
context!(logs, loggedin_user: &UserWithRoles::from_user(user.user, db).await),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/show")]
|
#[get("/show")]
|
||||||
async fn show_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie) -> Template {
|
async fn show_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie) -> Template {
|
||||||
let logs = Logbook::completed(db).await;
|
let logs = Logbook::completed(db).await;
|
||||||
@ -378,6 +388,7 @@ pub fn routes() -> Vec<Route> {
|
|||||||
new_kiosk,
|
new_kiosk,
|
||||||
show,
|
show,
|
||||||
show_kiosk,
|
show_kiosk,
|
||||||
|
show_for_year,
|
||||||
delete,
|
delete,
|
||||||
delete_kiosk
|
delete_kiosk
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user