show list of coxes
This commit is contained in:
@ -19,6 +19,7 @@ use tera::Context;
|
||||
|
||||
use crate::model::{
|
||||
notification::Notification,
|
||||
role::Role,
|
||||
user::{User, UserWithRoles},
|
||||
};
|
||||
|
||||
@ -53,6 +54,27 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
|
||||
Template::render("index", context.into_json())
|
||||
}
|
||||
|
||||
#[get("/steering")]
|
||||
async fn steering(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_>>) -> Template {
|
||||
let mut context = Context::new();
|
||||
if let Some(msg) = flash {
|
||||
context.insert("flash", &msg.into_inner());
|
||||
}
|
||||
|
||||
let bootskundige =
|
||||
User::all_with_role(db, &Role::find_by_name(db, "Bootsführer").await.unwrap()).await;
|
||||
|
||||
let mut coxes = User::all_with_role(db, &Role::find_by_name(db, "cox").await.unwrap()).await;
|
||||
|
||||
coxes.retain(|user| !bootskundige.contains(&user)); // Remove bootskundige from coxes list
|
||||
|
||||
context.insert("coxes", &coxes);
|
||||
context.insert("bootskundige", &bootskundige);
|
||||
|
||||
context.insert("loggedin_user", &UserWithRoles::from_user(user, db).await);
|
||||
Template::render("steering", context.into_json())
|
||||
}
|
||||
|
||||
#[post("/", data = "<login>")]
|
||||
async fn wikiauth(db: &State<SqlitePool>, login: Form<LoginForm<'_>>) -> String {
|
||||
match User::login(db, login.name, login.password).await {
|
||||
@ -86,7 +108,7 @@ pub struct Config {
|
||||
|
||||
pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
|
||||
rocket
|
||||
.mount("/", routes![index])
|
||||
.mount("/", routes![index, steering])
|
||||
.mount("/auth", auth::routes())
|
||||
.mount("/wikiauth", routes![wikiauth])
|
||||
.mount("/log", log::routes())
|
||||
|
Reference in New Issue
Block a user