fix ci; nicer explanation; subpages

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

@@ -1,7 +1,13 @@
use rocket::{get, http::ContentType, routes, Route, State};
use rocket::{get, http::ContentType, request::FlashMessage, routes, Route, State};
use sqlx::SqlitePool;
use crate::model::{event::Event, personal::cal::get_personal_cal, user::User};
use crate::model::{
event::Event,
personal::cal::get_personal_cal,
user::{User, UserWithDetails},
};
use rocket_dyn_templates::Template;
use tera::Context;
#[get("/cal")]
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
@@ -9,6 +15,19 @@ async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
(ContentType::Calendar, Event::get_ics_feed(db).await)
}
#[get("/kalender")]
async fn calinfo(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("loggedin_user", &UserWithDetails::from_user(user, db).await);
Template::render("calinfo", context.into_json())
}
#[get("/cal/personal/<user_id>/<uuid>")]
async fn cal_registered(
db: &State<SqlitePool>,
@@ -27,7 +46,7 @@ async fn cal_registered(
}
pub fn routes() -> Vec<Route> {
routes![cal, cal_registered]
routes![cal, cal_registered, calinfo]
}
#[cfg(test)]