From c3e5004ab37a5f454dfc44b713d7579a286160c2 Mon Sep 17 00:00:00 2001 From: kirbylife Date: Sat, 21 Dec 2019 03:55:39 -0600 Subject: [PATCH] fixed the edit page --- src/admin.rs | 8 +++----- templates/admin/edit_post.html.tera | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/admin.rs b/src/admin.rs index 28886c1..5b93cec 100644 --- a/src/admin.rs +++ b/src/admin.rs @@ -81,6 +81,8 @@ fn add_post(mut cookies: Cookies<'_>) -> Result { let context = get_context(); Ok(Template::render("admin/add_post", context)) + } else if cookie.value() == "123" { + Err(Redirect::to("/admin")) } else { Err(Redirect::to("/admin")) } @@ -119,11 +121,7 @@ fn edit_post(mut cookies: Cookies<'_>, id: i32) -> Result { let post = posts::get_post(id).unwrap(); - context.insert("id", &post.id); - context.insert("title", &post.title); - context.insert("content", &post.content); - context.insert("published", &post.published); - + context.insert("post", &post); Ok(Template::render("admin/edit_post", context)) } else { Err(Redirect::to("/admin")) diff --git a/templates/admin/edit_post.html.tera b/templates/admin/edit_post.html.tera index 280303e..0240cfd 100644 --- a/templates/admin/edit_post.html.tera +++ b/templates/admin/edit_post.html.tera @@ -26,11 +26,11 @@ {% block content %}
-
- + + - - + +