40 lines
1.1 KiB
Haskell
40 lines
1.1 KiB
Haskell
{-# LANGUAGE RecordWildCards #-}
|
|
{-# LANGUAGE NoImplicitPrelude #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
{-# LANGUAGE TypeFamilies #-}
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
{-# LANGUAGE TupleSections #-}
|
|
|
|
module Handler.Submission where
|
|
|
|
import Import
|
|
|
|
import Handler.Utils
|
|
|
|
import qualified Data.UUID.Cryptographic as UUID
|
|
|
|
|
|
getSubmissionListR :: Handler Html
|
|
getSubmissionListR = do
|
|
entityList <- runDB $ selectList [] []
|
|
cIDKey <- getsYesod appCryptoIDKey
|
|
let
|
|
cryptEntity :: Entity Submission -> Handler (CryptoUUIDSubmission, Submission)
|
|
cryptEntity (Entity key val) = (, val) <$> UUID.encrypt cIDKey (traceShowId key)
|
|
submissionList <- mapM cryptEntity entityList
|
|
defaultLayout $(widgetFile "submission-list")
|
|
|
|
|
|
getSubmissionR, postSubmissionR :: CryptoUUIDSubmission -> Handler Html
|
|
getSubmissionR = postSubmissionR
|
|
postSubmissionR cID = do
|
|
cIDKey <- getsYesod appCryptoIDKey
|
|
submissionID <- UUID.decrypt cIDKey cID
|
|
submission <- runDB $ get404 (submissionID :: Key Submission)
|
|
|
|
defaultLayout $ do
|
|
[whamlet|<pre>#{tshow submission}|]
|