Compare commits
61 Commits
main
...
aac99c86fa
Author | SHA1 | Date | |
---|---|---|---|
aac99c86fa | |||
2e13acc0b0 | |||
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 |
@@ -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)]
|
||||||
|
@@ -40,7 +40,7 @@ async fn index(
|
|||||||
let allowed_to_edit = AllowedToUpdateBoathouse::new(db, &admin.user)
|
let allowed_to_edit = AllowedToUpdateBoathouse::new(db, &admin.user)
|
||||||
.await
|
.await
|
||||||
.is_some();
|
.is_some();
|
||||||
context.insert("allowed_to_edit", &allowed_to_edit);
|
context.insert("allowed_to_edit", &boathouse);
|
||||||
|
|
||||||
context.insert(
|
context.insert(
|
||||||
"loggedin_user",
|
"loggedin_user",
|
||||||
|
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,
|
||||||
|
Reference in New Issue
Block a user