diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-04-15T21·09+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2018-04-15T21·09+0200 |
commit | 705097dab91c57524d2311dd839615840044437c (patch) | |
tree | 2b7763180fb25d3e85107a086b8fb1739e0e6688 /src/render.rs | |
parent | 7a557865528d6dba78b4dcb90248623aa100f930 (diff) |
feat(handlers/render): Display edit form for user's own posts
Displays an edit form for posts that are owned by a user (which is currently defined as "email addresses match").
Diffstat (limited to 'src/render.rs')
-rw-r--r-- | src/render.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/render.rs b/src/render.rs index c0a2fe88e697..e02ac31ea98c 100644 --- a/src/render.rs +++ b/src/render.rs @@ -200,7 +200,7 @@ impl Handler<NewThreadPage> for Renderer { type Result = Result<String>; fn handle(&mut self, msg: NewThreadPage, _: &mut Self::Context) -> Self::Result { - let ctx: FormContext = FormContext { + let ctx = FormContext { alerts: msg.alerts, title: msg.title, post: msg.post, @@ -210,6 +210,28 @@ impl Handler<NewThreadPage> for Renderer { } } +/// Message used to render post editing page. +pub struct EditPostPage { + pub id: i32, + pub post: String, +} +message!(EditPostPage, Result<String>); + +impl Handler<EditPostPage> for Renderer { + type Result = Result<String>; + + fn handle(&mut self, msg: EditPostPage, _: &mut Self::Context) -> Self::Result { + let ctx = FormContext { + mode: EditingMode::EditPost, + id: Some(msg.id), + post: Some(msg.post), + ..Default::default() + }; + + Ok(self.tera.render("post.html", &ctx)?) + } +} + /// Message used to render search results #[derive(Serialize)] pub struct SearchResultPage { |