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

View File

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

View File

@ -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>&nbsp;</p> <p>&nbsp;</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

View File

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