fixed resilient votes/comment after deletion
This commit is contained in:
parent
4dadfeb4e2
commit
e6d1c19711
1 changed files with 9 additions and 1 deletions
|
@ -142,7 +142,15 @@ deleteEntryR entryId = do
|
|||
case entries of
|
||||
[] -> errorPageJson "Either entry doesn't exists or not yours"
|
||||
_ -> do
|
||||
_ <- runDB $ delete entryId
|
||||
_ <- runDB $ do
|
||||
-- delete the entry
|
||||
delete entryId
|
||||
-- delete all corresponding votes
|
||||
votes <- selectList [VoteEntry ==. entryId][]
|
||||
mapM_ (\(Entity voteId _) -> delete voteId) votes
|
||||
-- delete all corresponding comments
|
||||
comments <- selectList [CommentEntry ==. entryId][]
|
||||
mapM_ (\(Entity commentId _) -> delete commentId) comments
|
||||
errorPageJson "deleted"
|
||||
|
||||
putEntryR :: EntryId -> Handler RepHtmlJson
|
||||
|
|
Loading…
Reference in a new issue