forked from Ruderverein-Donau-Linz/rowt
fix ci; nicer explanation; subpages
This commit is contained in:
@@ -11,6 +11,7 @@ use tera::Context;
|
||||
use crate::{
|
||||
model::{
|
||||
log::Log,
|
||||
notification::Notification,
|
||||
tripdetails::TripDetails,
|
||||
triptype::TripType,
|
||||
user::{User, UserWithDetails},
|
||||
@@ -47,9 +48,28 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
|
||||
);
|
||||
context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await);
|
||||
context.insert("days", &days);
|
||||
|
||||
Template::render("index", context.into_json())
|
||||
}
|
||||
|
||||
#[get("/notifications")]
|
||||
async fn notifications(
|
||||
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());
|
||||
}
|
||||
|
||||
context.insert("notifications", &Notification::for_user(db, &user).await);
|
||||
context.insert("loggedin_user", &UserWithDetails::from_user(user, db).await);
|
||||
|
||||
Template::render("notifications", context.into_json())
|
||||
}
|
||||
|
||||
#[get("/join/<trip_details_id>?<user_note>")]
|
||||
async fn join(
|
||||
db: &State<SqlitePool>,
|
||||
@@ -215,7 +235,7 @@ async fn remove(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Fla
|
||||
}
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![index, join, remove, remove_guest]
|
||||
routes![index, join, remove, remove_guest, notifications]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user