forked from filipg/gonito
Improve showing a single submission
This commit is contained in:
parent
4f6ba50156
commit
ff2112a745
@ -4,6 +4,7 @@ import Import
|
|||||||
|
|
||||||
import Handler.SubmissionView
|
import Handler.SubmissionView
|
||||||
import Handler.Shared
|
import Handler.Shared
|
||||||
|
import Handler.TagUtils
|
||||||
|
|
||||||
import Database.Persist.Sql
|
import Database.Persist.Sql
|
||||||
|
|
||||||
@ -72,6 +73,9 @@ postQueryFormR = do
|
|||||||
getQueryResultsR :: Text -> Handler Html
|
getQueryResultsR :: Text -> Handler Html
|
||||||
getQueryResultsR = processQuery
|
getQueryResultsR = processQuery
|
||||||
|
|
||||||
|
isFullQuery :: Text -> Bool
|
||||||
|
isFullQuery query = length query == 40
|
||||||
|
|
||||||
processQuery :: Text -> Handler Html
|
processQuery :: Text -> Handler Html
|
||||||
processQuery query = do
|
processQuery query = do
|
||||||
submissions <- findSubmissions query
|
submissions <- findSubmissions query
|
||||||
|
@ -3,6 +3,7 @@ module Handler.SubmissionView where
|
|||||||
import Import
|
import Import
|
||||||
import Handler.Shared
|
import Handler.Shared
|
||||||
import PersistSHA1
|
import PersistSHA1
|
||||||
|
import Handler.TagUtils
|
||||||
|
|
||||||
import Data.Text as T(pack)
|
import Data.Text as T(pack)
|
||||||
|
|
||||||
@ -13,7 +14,8 @@ data FullSubmissionInfo = FullSubmissionInfo {
|
|||||||
fsiRepo :: Repo,
|
fsiRepo :: Repo,
|
||||||
fsiChallenge :: Challenge,
|
fsiChallenge :: Challenge,
|
||||||
fsiChallengeRepo :: Repo,
|
fsiChallengeRepo :: Repo,
|
||||||
fsiScheme :: RepoScheme}
|
fsiScheme :: RepoScheme,
|
||||||
|
fsiTags :: [(Entity Tag, Entity SubmissionTag)] }
|
||||||
|
|
||||||
getFullInfo :: Entity Submission -> Handler FullSubmissionInfo
|
getFullInfo :: Entity Submission -> Handler FullSubmissionInfo
|
||||||
getFullInfo (Entity submissionId submission) = do
|
getFullInfo (Entity submissionId submission) = do
|
||||||
@ -22,6 +24,8 @@ getFullInfo (Entity submissionId submission) = do
|
|||||||
challenge <- runDB $ get404 $ submissionChallenge submission
|
challenge <- runDB $ get404 $ submissionChallenge submission
|
||||||
challengeRepo <- runDB $ get404 $ challengePublicRepo challenge
|
challengeRepo <- runDB $ get404 $ challengePublicRepo challenge
|
||||||
|
|
||||||
|
tags <- runDB $ getTags submissionId
|
||||||
|
|
||||||
app <- getYesod
|
app <- getYesod
|
||||||
let scheme = appRepoScheme $ appSettings app
|
let scheme = appRepoScheme $ appSettings app
|
||||||
|
|
||||||
@ -32,7 +36,8 @@ getFullInfo (Entity submissionId submission) = do
|
|||||||
fsiRepo = repo,
|
fsiRepo = repo,
|
||||||
fsiChallenge = challenge,
|
fsiChallenge = challenge,
|
||||||
fsiChallengeRepo = challengeRepo,
|
fsiChallengeRepo = challengeRepo,
|
||||||
fsiScheme = scheme}
|
fsiScheme = scheme,
|
||||||
|
fsiTags = tags }
|
||||||
|
|
||||||
|
|
||||||
queryResult submission = do
|
queryResult submission = do
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<div .subm-commit>#{commitSha1AsText}
|
<div .subm-commit>#{commitSha1AsText}
|
||||||
<div .subm-description>#{submissionDescription $ fsiSubmission submission}
|
<div .subm-description>^{fragmentWithTags (submissionDescription $ fsiSubmission submission) (map fst $ fsiTags submission)}
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
|
<dt>challenge
|
||||||
|
<dd><a href="@{ShowChallengeR $ challengeName $ fsiChallenge submission}">#{challengeTitle $ fsiChallenge submission}</a>
|
||||||
<dt>submitter
|
<dt>submitter
|
||||||
<dd>#{submitter}
|
<dd>#{submitter}
|
||||||
<dt>submitted
|
<dt>submitted
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<h2>Query results
|
$if not (isFullQuery query) || null submissions
|
||||||
|
<h2>Query results
|
||||||
|
|
||||||
$if null submissions
|
$if null submissions
|
||||||
<p>No results found.
|
<p>No results found.
|
||||||
|
Loading…
Reference in New Issue
Block a user