fix triggering an evaluation when running in the auto-opening mode

This commit is contained in:
Filip Gralinski 2018-09-01 10:48:08 +02:00
parent fac5d451d6
commit 0758ca3239
2 changed files with 12 additions and 6 deletions

View File

@ -11,11 +11,13 @@ import Data.Text as T
import Handler.Runner
getMakePublicR :: SubmissionId -> Handler TypedContent
getMakePublicR submissionId = runViewProgress $ doMakePublic submissionId
getMakePublicR submissionId = do
userId <- requireAuthId
runViewProgress $ doMakePublic userId submissionId
doMakePublic :: SubmissionId -> Channel -> Handler ()
doMakePublic submissionId chan = do
isOwner <- checkWhetherUserRepo submissionId
doMakePublic :: UserId -> SubmissionId -> Channel -> Handler ()
doMakePublic userId submissionId chan = do
isOwner <- checkWhetherGivenUserRepo userId submissionId
if not isOwner
then
err chan "Only the submitter can make a submission public!"
@ -48,6 +50,10 @@ pushRepo repoDir commit targetRepoUrl targetBranchName chan = do
checkWhetherUserRepo :: SubmissionId -> Handler Bool
checkWhetherUserRepo submissionId = do
submission <- runDB $ get404 submissionId
userId <- requireAuthId
checkWhetherGivenUserRepo userId submissionId
checkWhetherGivenUserRepo :: UserId -> SubmissionId -> Handler Bool
checkWhetherGivenUserRepo userId submissionId = do
submission <- runDB $ get404 submissionId
return $ userId == submissionSubmitter submission

View File

@ -244,7 +244,7 @@ doCreateSubmission userId challengeId mDescription mTags repoSpec chan = do
app <- getYesod
if appAutoOpening $ appSettings app
then
doMakePublic submissionId chan
doMakePublic userId submissionId chan
else
return ()
Nothing -> return ()