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();
|
let context = get_context();
|
||||||
|
|
||||||
Ok(Template::render("admin/add_post", context))
|
Ok(Template::render("admin/add_post", context))
|
||||||
|
} else if cookie.value() == "123" {
|
||||||
|
Err(Redirect::to("/admin"))
|
||||||
} else {
|
} else {
|
||||||
Err(Redirect::to("/admin"))
|
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();
|
let post = posts::get_post(id).unwrap();
|
||||||
|
|
||||||
context.insert("id", &post.id);
|
context.insert("post", &post);
|
||||||
context.insert("title", &post.title);
|
|
||||||
context.insert("content", &post.content);
|
|
||||||
context.insert("published", &post.published);
|
|
||||||
|
|
||||||
Ok(Template::render("admin/edit_post", context))
|
Ok(Template::render("admin/edit_post", context))
|
||||||
} else {
|
} else {
|
||||||
Err(Redirect::to("/admin"))
|
Err(Redirect::to("/admin"))
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="editable">
|
<div class="editable">
|
||||||
<form action="/admin/edit_post/{{ id }}" method="post">
|
<form action="/admin/edit_post/{{ post.id }}" method="post">
|
||||||
<input id="title" name="title" type="text" value={{ title }}/>
|
<input id="title" name="title" type="text" value="{{ post.title }}"/>
|
||||||
<label for="">Visible</label>
|
<label for="">Visible</label>
|
||||||
<input name="published" type="checkbox" value="true"{% if published %}checked{% endif %}/>
|
<input name="published" type="checkbox" value="true"{% if post.published %}checked{% endif %}/>
|
||||||
<textarea id="content" name="content">{{ content }}</textarea>
|
<textarea id="content" name="content">{{ post.content }}</textarea>
|
||||||
<button>Publicar</button>
|
<button>Publicar</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue