Merge branch 'staging' into 'main'
Staging See merge request PhilippHofer/rot!53
This commit is contained in:
commit
dee66525b4
@ -51,4 +51,16 @@ LIMIT 1000
|
|||||||
ret.push_str("</rss>");
|
ret.push_str("</rss>");
|
||||||
ret.replace('\n', "")
|
ret.replace('\n', "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn show(db: &SqlitePool) -> String {
|
||||||
|
let mut ret = String::new();
|
||||||
|
|
||||||
|
for log in Self::last(db).await {
|
||||||
|
let utc_time: DateTime<Utc> = Utc::from_utc_datetime(&Utc, &log.created_at);
|
||||||
|
let local_time = utc_time.with_timezone(&Local);
|
||||||
|
ret.push_str(&format!("- {} - {}\n", local_time, log.msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
ret
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,34 @@
|
|||||||
use rocket::{get, routes, Route, State};
|
use rocket::{get, routes, Route, State};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use crate::{model::log::Log, tera::Config};
|
use crate::{
|
||||||
|
model::{log::Log, user::AdminUser},
|
||||||
|
tera::Config,
|
||||||
|
};
|
||||||
|
|
||||||
pub mod boat;
|
pub mod boat;
|
||||||
pub mod planned_event;
|
pub mod planned_event;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
#[get("/rss?<key>")]
|
#[get("/rss?<key>")]
|
||||||
async fn rss(db: &State<SqlitePool>, key: Option<&str>, config: &State<Config>) -> String {
|
async fn rss(db: &State<SqlitePool>, key: &str, config: &State<Config>) -> String {
|
||||||
match key {
|
if key.eq(&config.rss_key) {
|
||||||
Some(key) if key.eq(&config.rss_key) => Log::generate_feed(db).await,
|
Log::generate_feed(db).await
|
||||||
_ => "Not allowed".to_string(),
|
} else {
|
||||||
|
"Not allowed".into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/rss", rank = 2)]
|
||||||
|
async fn show_rss(db: &State<SqlitePool>, _admin: AdminUser) -> String {
|
||||||
|
Log::show(db).await
|
||||||
|
}
|
||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
ret.append(&mut user::routes());
|
ret.append(&mut user::routes());
|
||||||
ret.append(&mut boat::routes());
|
ret.append(&mut boat::routes());
|
||||||
ret.append(&mut planned_event::routes());
|
ret.append(&mut planned_event::routes());
|
||||||
ret.append(&mut routes![rss]);
|
ret.append(&mut routes![rss, show_rss]);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use rocket::{get, http::ContentType, routes, Route, State};
|
use rocket::{get, http::ContentType, routes, Route, State};
|
||||||
use rocket_dyn_templates::{context, Template};
|
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use crate::model::{planned_event::PlannedEvent, user::User};
|
use crate::model::planned_event::PlannedEvent;
|
||||||
|
|
||||||
#[get("/cal")]
|
#[get("/cal")]
|
||||||
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
|
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
|
||||||
@ -16,10 +15,7 @@ pub fn routes() -> Vec<Route> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use rocket::{
|
use rocket::{http::Status, local::asynchronous::Client};
|
||||||
http::{ContentType, Status},
|
|
||||||
local::asynchronous::Client,
|
|
||||||
};
|
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use crate::testdb;
|
use crate::testdb;
|
||||||
|
@ -4,7 +4,7 @@ use sqlx::SqlitePool;
|
|||||||
|
|
||||||
use crate::model::{
|
use crate::model::{
|
||||||
stat::{self, Stat},
|
stat::{self, Stat},
|
||||||
user::{NonGuestUser, User},
|
user::NonGuestUser,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::log::KioskCookie;
|
use super::log::KioskCookie;
|
||||||
|
Loading…
Reference in New Issue
Block a user