forked from filipg/gonito
fix triggering an evaluation when running in the auto-opening mode
This commit is contained in:
parent
fac5d451d6
commit
0758ca3239
@ -11,11 +11,13 @@ import Data.Text as T
|
|||||||
import Handler.Runner
|
import Handler.Runner
|
||||||
|
|
||||||
getMakePublicR :: SubmissionId -> Handler TypedContent
|
getMakePublicR :: SubmissionId -> Handler TypedContent
|
||||||
getMakePublicR submissionId = runViewProgress $ doMakePublic submissionId
|
getMakePublicR submissionId = do
|
||||||
|
userId <- requireAuthId
|
||||||
|
runViewProgress $ doMakePublic userId submissionId
|
||||||
|
|
||||||
doMakePublic :: SubmissionId -> Channel -> Handler ()
|
doMakePublic :: UserId -> SubmissionId -> Channel -> Handler ()
|
||||||
doMakePublic submissionId chan = do
|
doMakePublic userId submissionId chan = do
|
||||||
isOwner <- checkWhetherUserRepo submissionId
|
isOwner <- checkWhetherGivenUserRepo userId submissionId
|
||||||
if not isOwner
|
if not isOwner
|
||||||
then
|
then
|
||||||
err chan "Only the submitter can make a submission public!"
|
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 -> Handler Bool
|
||||||
checkWhetherUserRepo submissionId = do
|
checkWhetherUserRepo submissionId = do
|
||||||
submission <- runDB $ get404 submissionId
|
|
||||||
userId <- requireAuthId
|
userId <- requireAuthId
|
||||||
|
checkWhetherGivenUserRepo userId submissionId
|
||||||
|
|
||||||
|
checkWhetherGivenUserRepo :: UserId -> SubmissionId -> Handler Bool
|
||||||
|
checkWhetherGivenUserRepo userId submissionId = do
|
||||||
|
submission <- runDB $ get404 submissionId
|
||||||
return $ userId == submissionSubmitter submission
|
return $ userId == submissionSubmitter submission
|
||||||
|
@ -244,7 +244,7 @@ doCreateSubmission userId challengeId mDescription mTags repoSpec chan = do
|
|||||||
app <- getYesod
|
app <- getYesod
|
||||||
if appAutoOpening $ appSettings app
|
if appAutoOpening $ appSettings app
|
||||||
then
|
then
|
||||||
doMakePublic submissionId chan
|
doMakePublic userId submissionId chan
|
||||||
else
|
else
|
||||||
return ()
|
return ()
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
|
Loading…
Reference in New Issue
Block a user