From c1ed05edf04d2488ee1eaebf65677bc97b88471b Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Fri, 4 Sep 2015 10:16:12 +0200 Subject: [PATCH] add challenge --- Handler/CreateChallenge.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Handler/CreateChallenge.hs b/Handler/CreateChallenge.hs index 25f3b1a..80e209f 100644 --- a/Handler/CreateChallenge.hs +++ b/Handler/CreateChallenge.hs @@ -33,9 +33,25 @@ doCreateChallenge name publicUrl publicBranch privateUrl privateBranch chan = do case maybePublicRepoId of Just publicRepoId -> do maybePrivateRepoId <- cloneRepo privateUrl privateBranch chan - return () + case maybePrivateRepoId of + Just privateRepoId -> addChallenge name publicRepoId privateRepoId chan + Nothing -> return () Nothing -> return () +addChallenge :: Text -> (Key Repo) -> (Key Repo) -> Channel -> Handler () +addChallenge name publicRepoId privateRepoId chan = do + msg chan "adding challenge..." + time <- liftIO getCurrentTime + challengeId <- runDB $ insert $ Challenge { + challengePublicRepo=publicRepoId, + challengePrivateRepo=privateRepoId, + challengeName=name, + challengeTitle="[UNKNOWN TITLE]", + challengeDescription="[UNKNOWN DESCRIPTION]", + challengeStamp=time} + return () + + sampleForm :: Form (Text, Text, Text, Text, Text) sampleForm = renderBootstrap3 BootstrapBasicForm $ (,,,,) <$> areq textField (fieldSettingsLabel MsgName) Nothing