Compare commits
59 Commits
main
...
6a59634de3
Author | SHA1 | Date | |
---|---|---|---|
6a59634de3 | |||
63a32f02bf | |||
429f0c1ddc | |||
0354e4e190 | |||
7935d1837f | |||
f769af279b | |||
de62585b64 | |||
ac24be6c5e | |||
13976b02d8 | |||
3aef4fa971 | |||
29e9911653 | |||
eca711e572 | |||
09aa0fc136 | |||
cc9505ca1e | |||
22f70f533a | |||
6df029b4a7 | |||
1d4d59842b | |||
a63d29a42a | |||
1f4ebc31ed | |||
50cd3c2d75 | |||
0edd796f73 | |||
e883c0e6e2 | |||
d2390ca5c2 | |||
4906b757b8 | |||
0b62f59d19 | |||
924683511c | |||
d7d6eb2b43 | |||
4859890389 | |||
4f34cc180c | |||
3c26381901 | |||
e01f9806bd | |||
71087af0df | |||
6efcaaccf9 | |||
60578dfaba | |||
addf0f437b | |||
51df7f2d1e | |||
78faf1b0db | |||
e3fc756b3f | |||
7083d27644 | |||
8277ef6af8 | |||
67d5df9c18 | |||
3ffc44a5a2 | |||
bd2686fa9c | |||
495ee666cd | |||
5296b6a6c1 | |||
49e657ab54 | |||
25bbaca0d3 | |||
26038eabe4 | |||
57acd92e7c | |||
c136c60e62 | |||
a5e90ea014 | |||
f0f3909239 | |||
1438bbe3a8 | |||
a910cd745d | |||
6265440288 | |||
3baed66ebc | |||
499ce06438 | |||
67e5277c62 | |||
ce154bf060 |
@@ -31,7 +31,7 @@ jobs:
|
|||||||
- Run `cargo upgrade` to update version requirements in Cargo.toml
|
- Run `cargo upgrade` to update version requirements in Cargo.toml
|
||||||
- Run `cargo update` to update Cargo.lock
|
- Run `cargo update` to update Cargo.lock
|
||||||
branch: update-cargo-dependencies
|
branch: update-cargo-dependencies
|
||||||
delete-branch: false
|
delete-branch: true
|
||||||
|
|
||||||
- name: Create Pull Request Main
|
- name: Create Pull Request Main
|
||||||
uses: https://git.hofer.link/philipp/create-pull-request@18ef1fdad70eec569ab10292c1fa79c1b5296370
|
uses: https://git.hofer.link/philipp/create-pull-request@18ef1fdad70eec569ab10292c1fa79c1b5296370
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use rocket::serde::{Deserialize, Serialize};
|
|
||||||
use rocket::FromForm;
|
use rocket::FromForm;
|
||||||
|
use rocket::serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||||
|
|
||||||
use crate::model::boathouse::Boathouse;
|
use crate::model::boathouse::Boathouse;
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
use rocket::serde::{Deserialize, Serialize};
|
use rocket::serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, SqlitePool};
|
use sqlx::{FromRow, SqlitePool};
|
||||||
|
|
||||||
use crate::{
|
use crate::tera::board::boathouse::FormBoathouseToAdd;
|
||||||
model::{log::Log, user::AllowedToUpdateBoathouse},
|
|
||||||
tera::board::boathouse::FormBoathouseToAdd,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::boat::Boat;
|
use super::boat::Boat;
|
||||||
|
|
||||||
@@ -117,11 +114,7 @@ impl Boathouse {
|
|||||||
BoathouseAisles::from(db, boathouses).await
|
BoathouseAisles::from(db, boathouses).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create(
|
pub async fn create(db: &SqlitePool, data: FormBoathouseToAdd) -> Result<(), String> {
|
||||||
db: &SqlitePool,
|
|
||||||
changed_by: &AllowedToUpdateBoathouse,
|
|
||||||
data: FormBoathouseToAdd,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO boathouse(boat_id, aisle, side, level) VALUES (?,?,?,?)",
|
"INSERT INTO boathouse(boat_id, aisle, side, level) VALUES (?,?,?,?)",
|
||||||
data.boat_id,
|
data.boat_id,
|
||||||
@@ -132,17 +125,6 @@ impl Boathouse {
|
|||||||
.execute(db)
|
.execute(db)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
let boat = Boat::find_by_id(db, data.boat_id).await.unwrap();
|
|
||||||
Log::create(
|
|
||||||
db,
|
|
||||||
format!(
|
|
||||||
"{changed_by} hat das Boot {boat} auf den Gang {}, Seite {}, und Höhe {} 'gelegt'.",
|
|
||||||
data.aisle, data.side, data.level
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,20 +135,10 @@ impl Boathouse {
|
|||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete(&self, db: &SqlitePool, changed_by: &AllowedToUpdateBoathouse) {
|
pub async fn delete(&self, db: &SqlitePool) {
|
||||||
sqlx::query!("DELETE FROM boathouse WHERE id=?", self.id)
|
sqlx::query!("DELETE FROM boathouse WHERE id=?", self.id)
|
||||||
.execute(db)
|
.execute(db)
|
||||||
.await
|
.await
|
||||||
.unwrap(); //Okay, because we can only create a Boat of a valid id
|
.unwrap(); //Okay, because we can only create a Boat of a valid id
|
||||||
|
|
||||||
let boat = Boat::find_by_id(db, self.boat_id as i32).await.unwrap();
|
|
||||||
Log::create(
|
|
||||||
db,
|
|
||||||
format!(
|
|
||||||
"{changed_by} hat das Boot {boat} von Gang {}, Seite {}, und Höhe {} gelöscht.",
|
|
||||||
self.aisle, self.side, self.level
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -342,33 +342,12 @@ impl User {
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Bootsführer mehr)"))
|
ActivityBuilder::new(&format!("{updated_by} hat {self} zum normalen Mitglied gemacht (keine Steuerperson/Schiffsführer mehr)"))
|
||||||
.user(self)
|
.user(self)
|
||||||
.save(db)
|
.save(db)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(old, new) if old == Some(bootsfuehrer.clone()) && new == Some(cox.clone()) => {
|
|
||||||
self.remove_role(db, updated_by, &bootsfuehrer).await?;
|
|
||||||
self.add_role(db, updated_by, &cox).await?;
|
|
||||||
Notification::create_for_role(
|
|
||||||
db,
|
|
||||||
&member,
|
|
||||||
&format!(
|
|
||||||
"Lieber Vorstand, {self} ist ab sofort kein Bootsführer:in mehr, sondern 'nur' mehr eine Steuerperson."
|
|
||||||
),
|
|
||||||
"Bootsführer--",
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
ActivityBuilder::new(&format!(
|
|
||||||
"{updated_by} hat {self} zur Steuerperson gemacht (kein Bootsführer mehr)"
|
|
||||||
))
|
|
||||||
.user(self)
|
|
||||||
.save(db)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
(old, new) => return Err(format!("Not allowed to change from {old:?} to {new:?}")),
|
(old, new) => return Err(format!("Not allowed to change from {old:?} to {new:?}")),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -529,13 +508,6 @@ impl User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn remove_membership_pdf(&self, db: &SqlitePool, updated_by: &ManageUserUser) {
|
pub(crate) async fn remove_membership_pdf(&self, db: &SqlitePool, updated_by: &ManageUserUser) {
|
||||||
ActivityBuilder::new(&format!(
|
|
||||||
"{updated_by} hat die Beitrittserklärung vom Beutzer gelöscht."
|
|
||||||
))
|
|
||||||
.user(self)
|
|
||||||
.save(db)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"UPDATE user SET membership_pdf = null where id = ?",
|
"UPDATE user SET membership_pdf = null where id = ?",
|
||||||
self.id
|
self.id
|
||||||
|
@@ -102,13 +102,6 @@ impl UserWithDetails {
|
|||||||
user,
|
user,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn allowed_to_row(&self) -> bool {
|
|
||||||
self.roles.contains(&"Donau Linz".into())
|
|
||||||
|| self.roles.contains(&"Förderndes Mitglied".into())
|
|
||||||
|| self.roles.contains(&"scheckbuch".into())
|
|
||||||
|| self.user.name == "Externe Steuerperson"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -866,7 +859,6 @@ special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
|
|||||||
special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
|
special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
|
||||||
special_user!(AllowedToSendFeeReminderUser, +"admin", +"schriftfuehrer", +"kassier");
|
special_user!(AllowedToSendFeeReminderUser, +"admin", +"schriftfuehrer", +"kassier");
|
||||||
special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin");
|
special_user!(AllowedToUpdateTripToAlwaysBeShownUser, +"admin");
|
||||||
special_user!(AllowedToUpdateBoathouse, +"admin", +"Vorstand", +"tech");
|
|
||||||
|
|
||||||
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
|
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct UserWithRolesAndMembershipPdf {
|
pub struct UserWithRolesAndMembershipPdf {
|
||||||
|
@@ -7,11 +7,11 @@ use crate::{
|
|||||||
mail::valid_mails,
|
mail::valid_mails,
|
||||||
role::Role,
|
role::Role,
|
||||||
user::{
|
user::{
|
||||||
|
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, User, UserWithDetails,
|
||||||
|
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
|
||||||
clubmember::ClubMemberUser, foerdernd::FoerderndUser, member::Member,
|
clubmember::ClubMemberUser, foerdernd::FoerderndUser, member::Member,
|
||||||
regular::RegularUser, scheckbuch::ScheckbuchUser, schnupperant::SchnupperantUser,
|
regular::RegularUser, scheckbuch::ScheckbuchUser, schnupperant::SchnupperantUser,
|
||||||
schnupperinterest::SchnupperInterestUser, unterstuetzend::UnterstuetzendUser,
|
schnupperinterest::SchnupperInterestUser, unterstuetzend::UnterstuetzendUser,
|
||||||
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, User, UserWithDetails,
|
|
||||||
UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tera::Config,
|
tera::Config,
|
||||||
@@ -19,6 +19,7 @@ use crate::{
|
|||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
FromForm, Request, Route, State,
|
||||||
form::Form,
|
form::Form,
|
||||||
fs::TempFile,
|
fs::TempFile,
|
||||||
get,
|
get,
|
||||||
@@ -26,9 +27,9 @@ use rocket::{
|
|||||||
post,
|
post,
|
||||||
request::{FlashMessage, FromRequest, Outcome},
|
request::{FlashMessage, FromRequest, Outcome},
|
||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes, FromForm, Request, Route, State,
|
routes,
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{Template, tera::Context};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
// Custom request guard to extract the Referer header
|
// Custom request guard to extract the Referer header
|
||||||
@@ -356,7 +357,7 @@ async fn add_note(
|
|||||||
match user.add_note(db, &admin, &data.note).await {
|
match user.add_note(db, &admin, &data.note).await {
|
||||||
Ok(_) => Flash::success(
|
Ok(_) => Flash::success(
|
||||||
Redirect::to(format!("/admin/user/{}", user.id)),
|
Redirect::to(format!("/admin/user/{}", user.id)),
|
||||||
"Notiz hinzugefügt. Du findest sie ab sofort unter 'Aktivitäten'.",
|
"Notiz hinzugefügt",
|
||||||
),
|
),
|
||||||
Err(e) => Flash::error(Redirect::to(format!("/admin/user/{}", user.id)), e),
|
Err(e) => Flash::error(Redirect::to(format!("/admin/user/{}", user.id)), e),
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
use crate::model::{
|
use crate::model::{
|
||||||
boat::Boat,
|
boat::Boat,
|
||||||
boathouse::Boathouse,
|
boathouse::Boathouse,
|
||||||
user::{AllowedToUpdateBoathouse, UserWithDetails, VorstandUser},
|
user::{AdminUser, UserWithDetails, VorstandUser},
|
||||||
};
|
};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
FromForm, Route, State,
|
||||||
form::Form,
|
form::Form,
|
||||||
get, post,
|
get, post,
|
||||||
request::FlashMessage,
|
request::FlashMessage,
|
||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes, FromForm, Route, State,
|
routes,
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{Template, tera::Context};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
#[get("/boathouse")]
|
#[get("/boathouse")]
|
||||||
@@ -37,11 +38,6 @@ async fn index(
|
|||||||
let boathouse = Boathouse::get(db).await;
|
let boathouse = Boathouse::get(db).await;
|
||||||
context.insert("boathouse", &boathouse);
|
context.insert("boathouse", &boathouse);
|
||||||
|
|
||||||
let allowed_to_edit = AllowedToUpdateBoathouse::new(db, &admin.user)
|
|
||||||
.await
|
|
||||||
.is_some();
|
|
||||||
context.insert("allowed_to_edit", &allowed_to_edit);
|
|
||||||
|
|
||||||
context.insert(
|
context.insert(
|
||||||
"loggedin_user",
|
"loggedin_user",
|
||||||
&UserWithDetails::from_user(admin.into_inner(), db).await,
|
&UserWithDetails::from_user(admin.into_inner(), db).await,
|
||||||
@@ -61,29 +57,36 @@ pub struct FormBoathouseToAdd {
|
|||||||
async fn new<'r>(
|
async fn new<'r>(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
data: Form<FormBoathouseToAdd>,
|
data: Form<FormBoathouseToAdd>,
|
||||||
user: AllowedToUpdateBoathouse,
|
_admin: AdminUser,
|
||||||
) -> Flash<Redirect> {
|
) -> Flash<Redirect> {
|
||||||
match Boathouse::create(db, &user, data.into_inner()).await {
|
match Boathouse::create(db, data.into_inner()).await {
|
||||||
Ok(_) => Flash::success(Redirect::to("/board/boathouse"), "Boot hinzugefügt"),
|
Ok(_) => Flash::success(Redirect::to("/board/boathouse"), "Boot hinzugefügt"),
|
||||||
Err(e) => Flash::error(Redirect::to("/board/boathouse"), e),
|
Err(e) => Flash::error(Redirect::to("/board/boathouse"), e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/boathouse/<boathouse_id>/delete")]
|
#[get("/boathouse/<boathouse_id>/delete")]
|
||||||
async fn delete(
|
async fn delete(db: &State<SqlitePool>, _admin: AdminUser, boathouse_id: i32) -> Flash<Redirect> {
|
||||||
db: &State<SqlitePool>,
|
|
||||||
user: AllowedToUpdateBoathouse,
|
|
||||||
boathouse_id: i32,
|
|
||||||
) -> Flash<Redirect> {
|
|
||||||
let boat = Boathouse::find_by_id(db, boathouse_id).await;
|
let boat = Boathouse::find_by_id(db, boathouse_id).await;
|
||||||
match boat {
|
match boat {
|
||||||
Some(boat) => {
|
Some(boat) => {
|
||||||
boat.delete(db, &user).await;
|
boat.delete(db).await;
|
||||||
Flash::success(Redirect::to("/board/boathouse"), "Bootsplatz gelöscht")
|
Flash::success(Redirect::to("/board/boathouse"), "Bootsplatz gelöscht")
|
||||||
}
|
}
|
||||||
None => Flash::error(Redirect::to("/board/boathouse"), "Boatplace does not exist"),
|
None => Flash::error(Redirect::to("/board/boathouse"), "Boatplace does not exist"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#[post("/boat/new", data = "<data>")]
|
||||||
|
//async fn create(
|
||||||
|
// db: &State<SqlitePool>,
|
||||||
|
// data: Form<BoatToAdd<'_>>,
|
||||||
|
// _admin: AdminUser,
|
||||||
|
//) -> Flash<Redirect> {
|
||||||
|
// match Boat::create(db, data.into_inner()).await {
|
||||||
|
// Ok(_) => Flash::success(Redirect::to("/admin/boat"), "Boot hinzugefügt"),
|
||||||
|
// Err(e) => Flash::error(Redirect::to("/admin/boat"), e),
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
routes![index, new, delete]
|
routes![index, new, delete]
|
||||||
|
117
src/tera/log.rs
117
src/tera/log.rs
@@ -47,44 +47,12 @@ impl<'r> FromRequest<'r> for KioskCookie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/", rank = 2)]
|
#[get("/", rank = 2)]
|
||||||
async fn index_loggedin(
|
async fn index(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
flash: Option<FlashMessage<'_>>,
|
flash: Option<FlashMessage<'_>>,
|
||||||
user: DonauLinzUser,
|
user: DonauLinzUser,
|
||||||
) -> Template {
|
) -> Template {
|
||||||
let mut context = Context::new();
|
|
||||||
|
|
||||||
let boats = Boat::for_user(db, &user).await;
|
let boats = Boat::for_user(db, &user).await;
|
||||||
context.insert("boats", &boats);
|
|
||||||
|
|
||||||
context.insert(
|
|
||||||
"loggedin_user",
|
|
||||||
&UserWithDetails::from_user(user.into_inner(), db).await,
|
|
||||||
);
|
|
||||||
|
|
||||||
index(db, flash, context).await
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/")]
|
|
||||||
async fn index_kiosk(
|
|
||||||
db: &State<SqlitePool>,
|
|
||||||
flash: Option<FlashMessage<'_>>,
|
|
||||||
_kiosk: KioskCookie,
|
|
||||||
) -> Template {
|
|
||||||
let mut context = Context::new();
|
|
||||||
|
|
||||||
let boats = Boat::all(db).await;
|
|
||||||
context.insert("boats", &boats);
|
|
||||||
|
|
||||||
context.insert("show_kiosk_header", &true);
|
|
||||||
|
|
||||||
index(db, flash, context).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn index(db: &SqlitePool, flash: Option<FlashMessage<'_>>, mut context: Context) -> Template {
|
|
||||||
if let Some(msg) = flash {
|
|
||||||
context.insert("flash", &msg.into_inner());
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
|
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
|
||||||
User::cox(db)
|
User::cox(db)
|
||||||
@@ -93,7 +61,9 @@ async fn index(db: &SqlitePool, flash: Option<FlashMessage<'_>>, mut context: Co
|
|||||||
.map(|user| UserWithDetails::from_user(user, db)),
|
.map(|user| UserWithDetails::from_user(user, db)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
coxes.retain(|u| u.roles.contains(&"Donau Linz".into()));
|
coxes.retain(|u| {
|
||||||
|
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
|
||||||
|
});
|
||||||
|
|
||||||
let mut users: Vec<UserWithDetails> = futures::future::join_all(
|
let mut users: Vec<UserWithDetails> = futures::future::join_all(
|
||||||
User::all(db)
|
User::all(db)
|
||||||
@@ -102,13 +72,23 @@ async fn index(db: &SqlitePool, flash: Option<FlashMessage<'_>>, mut context: Co
|
|||||||
.map(|user| UserWithDetails::from_user(user, db)),
|
.map(|user| UserWithDetails::from_user(user, db)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
users.retain(|u| u.allowed_to_row());
|
users.retain(|u| {
|
||||||
|
u.roles.contains(&"Donau Linz".into())
|
||||||
|
|| u.roles.contains(&"scheckbuch".into())
|
||||||
|
|| u.user.name == "Externe Steuerperson"
|
||||||
|
});
|
||||||
|
|
||||||
let logtypes = LogType::all(db).await;
|
let logtypes = LogType::all(db).await;
|
||||||
let distances = Distance::all(db).await;
|
let distances = Distance::all(db).await;
|
||||||
|
|
||||||
let on_water = Logbook::on_water(db).await;
|
let on_water = Logbook::on_water(db).await;
|
||||||
|
|
||||||
|
let mut context = Context::new();
|
||||||
|
if let Some(msg) = flash {
|
||||||
|
context.insert("flash", &msg.into_inner());
|
||||||
|
}
|
||||||
|
|
||||||
|
context.insert("boats", &boats);
|
||||||
context.insert("planned_trips", &Trip::get_for_today(db).await);
|
context.insert("planned_trips", &Trip::get_for_today(db).await);
|
||||||
context.insert(
|
context.insert(
|
||||||
"reservations",
|
"reservations",
|
||||||
@@ -117,10 +97,14 @@ async fn index(db: &SqlitePool, flash: Option<FlashMessage<'_>>, mut context: Co
|
|||||||
context.insert("coxes", &coxes);
|
context.insert("coxes", &coxes);
|
||||||
context.insert("users", &users);
|
context.insert("users", &users);
|
||||||
context.insert("logtypes", &logtypes);
|
context.insert("logtypes", &logtypes);
|
||||||
|
context.insert(
|
||||||
|
"loggedin_user",
|
||||||
|
&UserWithDetails::from_user(user.into_inner(), db).await,
|
||||||
|
);
|
||||||
context.insert("on_water", &on_water);
|
context.insert("on_water", &on_water);
|
||||||
context.insert("distances", &distances);
|
context.insert("distances", &distances);
|
||||||
|
|
||||||
Template::render("kiosk", context.into_json())
|
Template::render("log", context.into_json())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/show", rank = 3)]
|
#[get("/show", rank = 3)]
|
||||||
@@ -195,6 +179,63 @@ async fn new_kiosk(
|
|||||||
Redirect::to("/log")
|
Redirect::to("/log")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
async fn kiosk(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
flash: Option<FlashMessage<'_>>,
|
||||||
|
_kiosk: KioskCookie,
|
||||||
|
) -> Template {
|
||||||
|
let boats = Boat::all(db).await;
|
||||||
|
let mut coxes: Vec<UserWithDetails> = futures::future::join_all(
|
||||||
|
User::cox(db)
|
||||||
|
.await
|
||||||
|
.into_iter()
|
||||||
|
.map(|user| UserWithDetails::from_user(user, db)),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
coxes.retain(|u| {
|
||||||
|
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut users: Vec<UserWithDetails> = futures::future::join_all(
|
||||||
|
User::all(db)
|
||||||
|
.await
|
||||||
|
.into_iter()
|
||||||
|
.map(|user| UserWithDetails::from_user(user, db)),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
users.retain(|u| {
|
||||||
|
u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into())
|
||||||
|
});
|
||||||
|
|
||||||
|
let logtypes = LogType::all(db).await;
|
||||||
|
let distances = Distance::all(db).await;
|
||||||
|
|
||||||
|
let on_water = Logbook::on_water(db).await;
|
||||||
|
|
||||||
|
let mut context = Context::new();
|
||||||
|
if let Some(msg) = flash {
|
||||||
|
context.insert("flash", &msg.into_inner());
|
||||||
|
}
|
||||||
|
|
||||||
|
context.insert("planned_trips", &Trip::get_for_today(db).await);
|
||||||
|
context.insert("boats", &boats);
|
||||||
|
context.insert(
|
||||||
|
"reservations",
|
||||||
|
&BoatReservation::all_future_with_groups(db).await,
|
||||||
|
);
|
||||||
|
context.insert("coxes", &coxes);
|
||||||
|
context.insert("users", &users);
|
||||||
|
context.insert("logtypes", &logtypes);
|
||||||
|
context.insert("on_water", &on_water);
|
||||||
|
context.insert("distances", &distances);
|
||||||
|
context.insert("show_kiosk_header", &true);
|
||||||
|
|
||||||
|
Template::render("kiosk", context.into_json())
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_logbook(
|
async fn create_logbook(
|
||||||
db: &SqlitePool,
|
db: &SqlitePool,
|
||||||
data: Form<LogToAdd>,
|
data: Form<LogToAdd>,
|
||||||
@@ -527,11 +568,11 @@ async fn delete_kiosk(
|
|||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
routes![
|
routes![
|
||||||
index_loggedin,
|
index,
|
||||||
index_kiosk,
|
|
||||||
create,
|
create,
|
||||||
create_kiosk,
|
create_kiosk,
|
||||||
home,
|
home,
|
||||||
|
kiosk,
|
||||||
home_kiosk,
|
home_kiosk,
|
||||||
new_kiosk,
|
new_kiosk,
|
||||||
show,
|
show,
|
||||||
|
@@ -7,12 +7,12 @@
|
|||||||
{% set place = boathouse[aisle_name][side_name].boats %}
|
{% set place = boathouse[aisle_name][side_name].boats %}
|
||||||
{% if place[level] %}
|
{% if place[level] %}
|
||||||
{{ place[level].boat.name }}
|
{{ place[level].boat.name }}
|
||||||
{% if allowed_to_edit %}
|
{% if "admin" in loggedin_user.roles %}
|
||||||
<a class="btn btn-primary absolute end-0"
|
<a class="btn btn-primary absolute end-0"
|
||||||
href="/board/boathouse/{{ place[level].boathouse_id }}/delete">X</a>
|
href="/board/boathouse/{{ place[level].boathouse_id }}/delete">X</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif boats | length > 0 %}
|
{% elif boats | length > 0 %}
|
||||||
{% if allowed_to_edit %}
|
{% if "admin" in loggedin_user.roles %}
|
||||||
<details>
|
<details>
|
||||||
<summary>Kein Boot</summary>
|
<summary>Kein Boot</summary>
|
||||||
<form action="/board/boathouse" method="post" class="grid gap-3">
|
<form action="/board/boathouse" method="post" class="grid gap-3">
|
||||||
|
Reference in New Issue
Block a user