fix ci; nicer explanation; subpages
All checks were successful
CI/CD Pipeline / test (push) Successful in 7m26s
CI/CD Pipeline / deploy-main (push) Successful in 4m6s

This commit is contained in:
2024-12-11 20:15:08 +01:00
parent 64ca9826ea
commit 80f7120085
7 changed files with 203 additions and 12 deletions

View File

@@ -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)]