Improve showing a single submission

This commit is contained in:
Filip Gralinski 2018-11-10 11:20:17 +01:00
parent 4f6ba50156
commit ff2112a745
4 changed files with 16 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import Import
import Handler.SubmissionView
import Handler.Shared
import Handler.TagUtils
import Database.Persist.Sql
@ -72,6 +73,9 @@ postQueryFormR = do
getQueryResultsR :: Text -> Handler Html
getQueryResultsR = processQuery
isFullQuery :: Text -> Bool
isFullQuery query = length query == 40
processQuery :: Text -> Handler Html
processQuery query = do
submissions <- findSubmissions query

View File

@ -3,6 +3,7 @@ module Handler.SubmissionView where
import Import
import Handler.Shared
import PersistSHA1
import Handler.TagUtils
import Data.Text as T(pack)
@ -13,7 +14,8 @@ data FullSubmissionInfo = FullSubmissionInfo {
fsiRepo :: Repo,
fsiChallenge :: Challenge,
fsiChallengeRepo :: Repo,
fsiScheme :: RepoScheme}
fsiScheme :: RepoScheme,
fsiTags :: [(Entity Tag, Entity SubmissionTag)] }
getFullInfo :: Entity Submission -> Handler FullSubmissionInfo
getFullInfo (Entity submissionId submission) = do
@ -22,6 +24,8 @@ getFullInfo (Entity submissionId submission) = do
challenge <- runDB $ get404 $ submissionChallenge submission
challengeRepo <- runDB $ get404 $ challengePublicRepo challenge
tags <- runDB $ getTags submissionId
app <- getYesod
let scheme = appRepoScheme $ appSettings app
@ -32,7 +36,8 @@ getFullInfo (Entity submissionId submission) = do
fsiRepo = repo,
fsiChallenge = challenge,
fsiChallengeRepo = challengeRepo,
fsiScheme = scheme}
fsiScheme = scheme,
fsiTags = tags }
queryResult submission = do

View File

@ -1,7 +1,9 @@
<div .subm-commit>#{commitSha1AsText}
<div .subm-description>#{submissionDescription $ fsiSubmission submission}
<div .subm-description>^{fragmentWithTags (submissionDescription $ fsiSubmission submission) (map fst $ fsiTags submission)}
<p>&nbsp;</p>
<dl class="dl-horizontal">
<dt>challenge
<dd><a href="@{ShowChallengeR $ challengeName $ fsiChallenge submission}">#{challengeTitle $ fsiChallenge submission}</a>
<dt>submitter
<dd>#{submitter}
<dt>submitted

View File

@ -1,4 +1,5 @@
<h2>Query results
$if not (isFullQuery query) || null submissions
<h2>Query results
$if null submissions
<p>No results found.