Skip to content
Permalink
Browse files

posts: delete button

  • Loading branch information...
3v0k4 committed Jul 20, 2019
1 parent 716817e commit 4fea7c6460f73615d615ba03e46e157c4e949424
Showing with 9 additions and 0 deletions.
  1. +1 −0 config/routes
  2. +1 −0 src/Foundation.hs
  3. +5 −0 src/Handler/Posts.hs
  4. +2 −0 templates/posts.hamlet
@@ -14,3 +14,4 @@
/profile ProfileR GET
/ LandingR GET POST
/posts PostsR GET POST
/posts/#PostId PostR DELETE
@@ -174,6 +174,7 @@ instance Yesod App where
isAuthorized LandingR _ = return Authorized

isAuthorized PostsR _ = return Authorized
isAuthorized (PostR _) _ = return Authorized

-- This function creates static content files in the static folder
-- and names them based on a hash of their content. This allows
@@ -33,3 +33,8 @@ postPostsR = do
_ ->
emptyLayout $ do
$(widgetFile "posts")

deletePostR :: PostId -> Handler Html
deletePostR postId = do
_ <- runDB $ delete postId
redirect PostsR
@@ -13,3 +13,5 @@
<li>
<h2> #{postTitle $ entityVal post}
<p> #{postText $ entityVal post}
<form method=post action=@{PostR $ entityKey post}?_method=DELETE>
<button>Delete

0 comments on commit 4fea7c6

Please sign in to comment.
You can’t perform that action at this time.