add table for courses, challenge could be selected for an achievement
This commit is contained in:
parent
63806e7e61
commit
0a745175aa
@ -30,11 +30,8 @@ postAchievementsR = do
|
|||||||
mUser <- maybeAuth
|
mUser <- maybeAuth
|
||||||
when (checkIfAdmin mUser) $ do
|
when (checkIfAdmin mUser) $ do
|
||||||
case result of
|
case result of
|
||||||
FormSuccess (name, description, points, deadlineDay, deadlineTime, maxSubmitters, mTags) -> do
|
FormSuccess (name, description, points, deadlineDay, deadlineTime, maxSubmitters, mTags, challengeId) -> do
|
||||||
-- @TODO for the time being hardcoded
|
achievementId <- runDB $ insert $ Achievement name challengeId points description (UTCTime { utctDay = deadlineDay, utctDayTime = timeOfDayToTime deadlineTime }) maxSubmitters
|
||||||
Just challengeEnt <- runDB $ getBy $ UniqueName "petite-difference-challenge2"
|
|
||||||
|
|
||||||
achievementId <- runDB $ insert $ Achievement name (entityKey challengeEnt) points description (UTCTime { utctDay = deadlineDay, utctDayTime = timeOfDayToTime deadlineTime }) maxSubmitters
|
|
||||||
|
|
||||||
tids <- runDB $ tagsAsTextToTagIds mTags
|
tids <- runDB $ tagsAsTextToTagIds mTags
|
||||||
|
|
||||||
@ -162,8 +159,8 @@ formatMaxSubmitters :: Maybe Int -> String
|
|||||||
formatMaxSubmitters Nothing = "no limit"
|
formatMaxSubmitters Nothing = "no limit"
|
||||||
formatMaxSubmitters (Just m) = show m
|
formatMaxSubmitters (Just m) = show m
|
||||||
|
|
||||||
achievementForm :: Form (Text, Maybe Text, Int, Day, TimeOfDay, Maybe Int, Maybe Text)
|
achievementForm :: Form (Text, Maybe Text, Int, Day, TimeOfDay, Maybe Int, Maybe Text, ChallengeId)
|
||||||
achievementForm = renderBootstrap3 BootstrapBasicForm $ (,,,,,,)
|
achievementForm = renderBootstrap3 BootstrapBasicForm $ (,,,,,,,)
|
||||||
<$> areq textField (bfs MsgAchievementName) Nothing
|
<$> areq textField (bfs MsgAchievementName) Nothing
|
||||||
<*> aopt textField (bfs MsgAchievementDescription) Nothing
|
<*> aopt textField (bfs MsgAchievementDescription) Nothing
|
||||||
<*> areq intField (bfs MsgAchievementPoints) Nothing
|
<*> areq intField (bfs MsgAchievementPoints) Nothing
|
||||||
@ -171,3 +168,10 @@ achievementForm = renderBootstrap3 BootstrapBasicForm $ (,,,,,,)
|
|||||||
<*> areq timeFieldTypeTime (bfs MsgAchievementDeadlineTime) Nothing
|
<*> areq timeFieldTypeTime (bfs MsgAchievementDeadlineTime) Nothing
|
||||||
<*> aopt intField (bfs MsgAchievementMaxWinners) Nothing
|
<*> aopt intField (bfs MsgAchievementMaxWinners) Nothing
|
||||||
<*> aopt textField (tagsfs MsgAchievementTags) Nothing
|
<*> aopt textField (tagsfs MsgAchievementTags) Nothing
|
||||||
|
<*> challengesSelectFieldList
|
||||||
|
|
||||||
|
challengesSelectFieldList = areq (selectField challenges) (bfs MsgChallenge) Nothing
|
||||||
|
where
|
||||||
|
challenges = do
|
||||||
|
challengeEnts <- runDB $ selectList [] [Asc ChallengeTitle]
|
||||||
|
optionsPairs $ Import.map (\ch -> (challengeTitle $ entityVal ch, entityKey ch)) challengeEnts
|
||||||
|
@ -101,4 +101,7 @@ WorkingOn
|
|||||||
user UserId
|
user UserId
|
||||||
finalSubmission SubmissionId Maybe
|
finalSubmission SubmissionId Maybe
|
||||||
UniqueWorkingOnAchievementUser achievement user
|
UniqueWorkingOnAchievementUser achievement user
|
||||||
|
Course
|
||||||
|
name Text
|
||||||
|
UniqueCourseName name
|
||||||
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
|
-- By default this file is used in Model.hs (which is imported by Foundation.hs)
|
||||||
|
@ -48,3 +48,4 @@ WantToBeAnonimised: I want to stay anonymous for other user of Gonito.net
|
|||||||
YourScore: your score
|
YourScore: your score
|
||||||
PasswordForNewAccount: enter a password for your new account
|
PasswordForNewAccount: enter a password for your new account
|
||||||
SubmissionDescriptionTooltip: the first non-empty line of the commit message will be used, if this is left empty
|
SubmissionDescriptionTooltip: the first non-empty line of the commit message will be used, if this is left empty
|
||||||
|
Challenge: challenge
|
||||||
|
Loading…
Reference in New Issue
Block a user