gonito/Handler/ListChallenges.hs
2019-03-20 16:31:08 +01:00

27 lines
940 B
Haskell

module Handler.ListChallenges where
import Import
getListChallengesR :: Handler Html
getListChallengesR = generalListChallenges [ChallengeArchived !=. Just True]
getListArchivedChallengesR :: Handler Html
getListArchivedChallengesR = generalListChallenges [ChallengeArchived ==. Just True]
generalListChallenges filterExpr = do
challenges <- runDB $ selectList filterExpr [Desc ChallengeStarred, Desc ChallengeStamp]
defaultLayout $ do
setTitle "List challenges"
$(widgetFile "list-challenges")
listChallengesCore challenges = $(widgetFile "list-challenges-core")
getChallengeImageR :: ChallengeId -> Handler Html
getChallengeImageR challengeId = do
challenge <- runDB $ get404 challengeId
case challengeImage challenge of
Just image -> do
addHeader "Content-Disposition" "attachment; filename=\"image.png\""
sendResponse (typePng, toContent image)
Nothing -> sendResponseStatus status202 ()