From f9498828c46156c2c231488ddfcedf3045f90970 Mon Sep 17 00:00:00 2001 From: Trinity Pointard Date: Thu, 11 Oct 2018 14:23:23 +0200 Subject: [PATCH] Modify post slug only when it's still drafted Fix #207 --- src/routes/posts.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 6cd4652..f642946 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -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 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() { Ok(_) => ValidationErrors::new(),