fixed the edit page
parent
4f8ca9acae
commit
c3e5004ab3
|
@ -81,6 +81,8 @@ fn add_post(mut cookies: Cookies<'_>) -> Result<Template, Redirect> {
|
|||
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<Template, Redirect> {
|
|||
|
||||
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"))
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="editable">
|
||||
<form action="/admin/edit_post/{{ id }}" method="post">
|
||||
<input id="title" name="title" type="text" value={{ title }}/>
|
||||
<form action="/admin/edit_post/{{ post.id }}" method="post">
|
||||
<input id="title" name="title" type="text" value="{{ post.title }}"/>
|
||||
<label for="">Visible</label>
|
||||
<input name="published" type="checkbox" value="true"{% if published %}checked{% endif %}/>
|
||||
<textarea id="content" name="content">{{ content }}</textarea>
|
||||
<input name="published" type="checkbox" value="true"{% if post.published %}checked{% endif %}/>
|
||||
<textarea id="content" name="content">{{ post.content }}</textarea>
|
||||
<button>Publicar</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue