forked from filipg/gonito
Repo details are not shown by default
This commit is contained in:
parent
9f4942a657
commit
324107c89c
@ -83,12 +83,11 @@ getPossibleAchievements userId submissionId = do
|
||||
doEditSubmission formWidget formEnctype submissionId mVariantId = do
|
||||
submission <- runDB $ get404 submissionId
|
||||
submissionFull <- getFullInfo (Entity submissionId submission)
|
||||
let view = queryResult submissionFull
|
||||
(Entity userId _) <- requireAuth
|
||||
let view = queryResult (Just userId) submissionFull
|
||||
|
||||
tagsAvailableAsJSON <- runDB $ getAvailableTagsAsJSON
|
||||
|
||||
(Entity userId _) <- requireAuth
|
||||
|
||||
achievements <- runDB $ getPossibleAchievements userId submissionId
|
||||
|
||||
variantParams <- case mVariantId of
|
||||
|
@ -149,7 +149,6 @@ groupBySecond lst = map putOut $ groupOn (fsiSubmissionId . fst) lst
|
||||
|
||||
findSubmissions :: Text -> Handler [(FullSubmissionInfo, [SHA1])]
|
||||
findSubmissions sha1Prefix = do
|
||||
mauthId <- maybeAuth
|
||||
allSubmissions <- runDB $ rawCommitQuery sha1Prefix
|
||||
justSubmissions' <- mapM getFullInfo allSubmissions
|
||||
let justSubmissions = map (\s -> (s, [])) justSubmissions'
|
||||
@ -275,6 +274,8 @@ isFullQuery query = length query == 40
|
||||
|
||||
processQuery :: Text -> Handler Html
|
||||
processQuery query = do
|
||||
mUserId <- maybeAuthId
|
||||
|
||||
submissions' <- findSubmissions query
|
||||
let submissions = map fst submissions'
|
||||
defaultLayout $ do
|
||||
@ -365,7 +366,6 @@ data ViewVariantData = ViewVariantData {
|
||||
|
||||
fetchViewVariantData :: VariantId -> Handler ViewVariantData
|
||||
fetchViewVariantData variantId = do
|
||||
mauthId <- maybeAuth
|
||||
variant <- runDB $ get404 variantId
|
||||
let theSubmissionId = variantSubmission variant
|
||||
theSubmission <- runDB $ get404 theSubmissionId
|
||||
@ -423,6 +423,8 @@ nullSHA1 = fromTextToSHA1 "da39a3ee5e6b4b0d3255bfef95601890afd80709"
|
||||
|
||||
doViewVariantTestR :: Diff VariantId -> TestId -> Handler Html
|
||||
doViewVariantTestR variantId testId = do
|
||||
mUserId <- maybeAuthId
|
||||
|
||||
testSelected <- runDB $ get404 testId
|
||||
let testSelectedEnt = Entity testId testSelected
|
||||
|
||||
@ -504,7 +506,7 @@ maximumNumberOfItemsToBeShown :: Int
|
||||
maximumNumberOfItemsToBeShown = 40
|
||||
|
||||
getOut :: Maybe UserId -> TableEntry -> WidgetFor App (Maybe (FilePath, FilePath))
|
||||
getOut mauthId entry = do
|
||||
getOut _ entry = do
|
||||
let variant = variantName $ entityVal $ tableEntryVariant entry
|
||||
|
||||
let isViewable = True
|
||||
@ -691,8 +693,16 @@ adjustNumberOfColumnsShown maximumNumberOfColumns tests = adjustNumberOfColumnsS
|
||||
minimumNumberOfTests = 2
|
||||
|
||||
|
||||
submissionHeader :: Diff (FullSubmissionInfo, Maybe Text) -> WidgetFor App ()
|
||||
submissionHeader param =
|
||||
canFullInfoBeShown (OneThing (fsi, _)) mUserId = checkWhetherVisible (fsiSubmission fsi) mUserId
|
||||
canFullInfoBeShown (TwoThings (fsiA, _) (fsiB, _)) mUserId = do
|
||||
checkA <- checkWhetherVisible (fsiSubmission fsiA) mUserId
|
||||
checkB <- checkWhetherVisible (fsiSubmission fsiB) mUserId
|
||||
return (checkA && checkB)
|
||||
|
||||
submissionHeader :: Maybe UserId -> Diff (FullSubmissionInfo, Maybe Text) -> WidgetFor App ()
|
||||
submissionHeader mUserId param = do
|
||||
showFullInfo <- handlerToWidget $ runDB $ canFullInfoBeShown param mUserId
|
||||
|
||||
$(widgetFile "submission-header")
|
||||
where variantSettings = ("out", ())
|
||||
submission = fst <$> param
|
||||
@ -707,9 +717,8 @@ submissionHeader param =
|
||||
submissionToSubmissionUrl submission' = getReadOnlySubmissionUrl (fsiScheme submission') (fsiChallengeRepo submission') $ challengeName $ fsiChallenge submission'
|
||||
submissionToBrowsableUrl submission' = browsableGitRepoBranch (fsiScheme submission') (fsiChallengeRepo submission') (challengeName $ fsiChallenge submission') (getPublicSubmissionBranch $ fsiSubmissionId submission')
|
||||
|
||||
|
||||
queryResult :: FullSubmissionInfo -> WidgetFor App ()
|
||||
queryResult submission = do
|
||||
queryResult :: Maybe UserId -> FullSubmissionInfo -> WidgetFor App ()
|
||||
queryResult mUserId submission = do
|
||||
$(widgetFile "query-result")
|
||||
|
||||
queryForm :: Form Text
|
||||
|
@ -295,19 +295,9 @@ statusCellWidget challengeName repoScheme challengeRepo (submissionId, submissio
|
||||
Nothing
|
||||
|
||||
getInfoLink :: Submission -> Maybe UserId -> Maybe (Route App)
|
||||
getInfoLink submission mauthId = if checkSimpleVisibility submission mauthId
|
||||
then Just $ QueryResultsR commitHash
|
||||
else Nothing
|
||||
getInfoLink submission _ = Just $ QueryResultsR commitHash
|
||||
where commitHash = fromSHA1ToText $ submissionCommit submission
|
||||
|
||||
-- sometimes we checker whether we got a teacher, but sometimes
|
||||
-- fall back to a simpler check...
|
||||
checkSimpleVisibility :: Submission -> Maybe UserId -> Bool
|
||||
checkSimpleVisibility submission mauthId = isPublic || isOwner
|
||||
where isPublic = submissionIsPublic submission
|
||||
isOwner = (mauthId == Just userId)
|
||||
userId = submissionSubmitter submission
|
||||
|
||||
checkWhetherVisible :: (MonadIO m, BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistUniqueRead backend)
|
||||
=> Submission -> Maybe (Key User) -> ReaderT backend m Bool
|
||||
checkWhetherVisible submission Nothing = return $ submissionIsPublic submission
|
||||
|
@ -3,10 +3,10 @@
|
||||
<p class="media-object">
|
||||
<span class="glyphicon glyphicon-asterisk" aria-hidden="hidden">
|
||||
<div class="media-body">
|
||||
^{submissionHeader (OneThing (submission, Nothing))}
|
||||
^{submissionHeader mUserId (OneThing (submission, Nothing))}
|
||||
^{resultTable (Entity (fsiSubmissionId submission) (fsiSubmission submission))}
|
||||
|
||||
$if not (null (fsiSuperSubmissions submission))
|
||||
<h4>downstream submissions
|
||||
$forall superSubmission <- (fsiSuperSubmissions submission)
|
||||
^{queryResult superSubmission}
|
||||
^{queryResult mUserId superSubmission}
|
||||
|
@ -5,5 +5,5 @@ $if null submissions
|
||||
<p>No results found.
|
||||
$else
|
||||
$forall submission <- submissions
|
||||
^{queryResult submission}
|
||||
^{queryResult mUserId submission}
|
||||
<hr>
|
||||
|
@ -10,12 +10,13 @@
|
||||
<dd>#{submitter}
|
||||
<dt>submitted
|
||||
<dd>#{stamp}
|
||||
<dt>original repo
|
||||
<dd>
|
||||
$maybe (url, branchPart) <- getHttpLink (fsiRepo $ current submission)
|
||||
<code><a href="#{url}">#{repoUrl $ fsiRepo $ current submission}</code></a> / branch <a href="#{url <> branchPart}"><code>#{repoBranch $ fsiRepo $ current submission}</code></a>
|
||||
$nothing
|
||||
<code>#{repoUrl $ fsiRepo $ current submission}</code> / branch <code>#{repoBranch $ fsiRepo $ current submission}</code>
|
||||
$if showFullInfo
|
||||
<dt>original repo
|
||||
<dd>
|
||||
$maybe (url, branchPart) <- getHttpLink (fsiRepo $ current submission)
|
||||
<code><a href="#{url}">#{repoUrl $ fsiRepo $ current submission}</code></a> / branch <a href="#{url <> branchPart}"><code>#{repoBranch $ fsiRepo $ current submission}</code></a>
|
||||
$nothing
|
||||
<code>#{repoUrl $ fsiRepo $ current submission}</code> / branch <code>#{repoBranch $ fsiRepo $ current submission}</code>
|
||||
$if submissionIsPublic $ fsiSubmission $ current submission
|
||||
<dt>publicly available at
|
||||
<dd><code>#{publicSubmissionRepo}</code> / branch <code>#{publicSubmissionBranch}</code>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<p class="media-object">
|
||||
<span class="glyphicon glyphicon-asterisk" aria-hidden="hidden">
|
||||
<div class="media-body">
|
||||
^{submissionHeader fullSubmissionInfo}
|
||||
^{submissionHeader mUserId fullSubmissionInfo}
|
||||
|
||||
$case tableEntryParams <$> entry
|
||||
$of OneThing []
|
||||
|
Loading…
Reference in New Issue
Block a user