read only published articles
This commit is contained in:
parent
e87ae641f7
commit
d1c85d409a
|
@ -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,6 +52,9 @@ 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 {
|
||||||
|
if !self.published {
|
||||||
|
writeln!(f, "this post has not yet been published!")
|
||||||
|
} else {
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
"\n{:<60} | published: {:<5}\n{:=^140}\n\n{}",
|
"\n{:<60} | published: {:<5}\n{:=^140}\n\n{}",
|
||||||
|
@ -59,6 +62,7 @@ impl Display for Post {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Insertable, Debug)]
|
#[derive(Insertable, Debug)]
|
||||||
#[diesel(table_name = crate::schema::posts)]
|
#[diesel(table_name = crate::schema::posts)]
|
||||||
|
|
Loading…
Reference in New Issue