Modify post slug only when it's still drafted

Fix #207
This commit is contained in:
Trinity Pointard 2018-10-11 14:23:23 +02:00
parent ed5bafbbc4
commit f9498828c4
1 changed files with 5 additions and 1 deletions

View File

@ -155,7 +155,11 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor
let mut post = b.clone().and_then(|blog| Post::find_by_slug(&*conn, slug.clone(), blog.id)).expect("Post to update not found"); let mut post = b.clone().and_then(|blog| Post::find_by_slug(&*conn, slug.clone(), blog.id)).expect("Post to update not found");
let form = data.get(); let form = data.get();
let new_slug = form.title.to_string().to_kebab_case(); let new_slug = if !post.published {
form.title.to_string().to_kebab_case()
} else {
post.slug
};
let mut errors = match form.validate() { let mut errors = match form.validate() {
Ok(_) => ValidationErrors::new(), Ok(_) => ValidationErrors::new(),