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.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 sqlx::SqlitePool;
|
||||
|
||||
use crate::{model::log::Log, tera::Config};
|
||||
use crate::{
|
||||
model::{log::Log, user::AdminUser},
|
||||
tera::Config,
|
||||
};
|
||||
|
||||
pub mod boat;
|
||||
pub mod planned_event;
|
||||
pub mod user;
|
||||
|
||||
#[get("/rss?<key>")]
|
||||
async fn rss(db: &State<SqlitePool>, key: Option<&str>, config: &State<Config>) -> String {
|
||||
match key {
|
||||
Some(key) if key.eq(&config.rss_key) => Log::generate_feed(db).await,
|
||||
_ => "Not allowed".to_string(),
|
||||
async fn rss(db: &State<SqlitePool>, key: &str, config: &State<Config>) -> String {
|
||||
if key.eq(&config.rss_key) {
|
||||
Log::generate_feed(db).await
|
||||
} 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> {
|
||||
let mut ret = Vec::new();
|
||||
ret.append(&mut user::routes());
|
||||
ret.append(&mut boat::routes());
|
||||
ret.append(&mut planned_event::routes());
|
||||
ret.append(&mut routes![rss]);
|
||||
ret.append(&mut routes![rss, show_rss]);
|
||||
ret
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
use rocket::{get, http::ContentType, routes, Route, State};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{planned_event::PlannedEvent, user::User};
|
||||
use crate::model::planned_event::PlannedEvent;
|
||||
|
||||
#[get("/cal")]
|
||||
async fn cal(db: &State<SqlitePool>) -> (ContentType, String) {
|
||||
@ -16,10 +15,7 @@ pub fn routes() -> Vec<Route> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use rocket::{
|
||||
http::{ContentType, Status},
|
||||
local::asynchronous::Client,
|
||||
};
|
||||
use rocket::{http::Status, local::asynchronous::Client};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::testdb;
|
||||
|
@ -4,7 +4,7 @@ use sqlx::SqlitePool;
|
||||
|
||||
use crate::model::{
|
||||
stat::{self, Stat},
|
||||
user::{NonGuestUser, User},
|
||||
user::NonGuestUser,
|
||||
};
|
||||
|
||||
use super::log::KioskCookie;
|
||||
|
Loading…
Reference in New Issue
Block a user