read only published articles

This commit is contained in:
Christoph J. Scherr 2024-06-27 13:53:31 +02:00
parent e87ae641f7
commit d1c85d409a
1 changed files with 10 additions and 6 deletions

View File

@ -2,7 +2,7 @@ use std::fmt::Display;
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use diesel::prelude::*; use diesel::prelude::*;
use libpt::log::{info, trace}; use libpt::log::{info, trace, warn};
use crate::schema::posts; use crate::schema::posts;
@ -52,11 +52,15 @@ impl Post {
impl Display for Post { impl Display for Post {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!( if !self.published {
f, writeln!(f, "this post has not yet been published!")
"\n{:<60} | published: {:<5}\n{:=^140}\n\n{}", } else {
self.title, self.published, "", self.body writeln!(
) f,
"\n{:<60} | published: {:<5}\n{:=^140}\n\n{}",
self.title, self.published, "", self.body
)
}
} }
} }