fixed resilient votes/comment after deletion

This commit is contained in:
Yann Esposito 2012-08-21 10:22:30 +02:00
parent 4dadfeb4e2
commit e6d1c19711

View file

@ -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