forked from filipg/gonito
add points to achievements
This commit is contained in:
parent
a8b8b1e5c8
commit
bce4d4768e
@ -25,11 +25,11 @@ postAchievementsR = do
|
|||||||
mUser <- maybeAuth
|
mUser <- maybeAuth
|
||||||
when (checkIfAdmin mUser) $ do
|
when (checkIfAdmin mUser) $ do
|
||||||
case result of
|
case result of
|
||||||
FormSuccess (name, description, deadlineDay, deadlineTime, maxSubmitters, mTags) -> do
|
FormSuccess (name, description, points, deadlineDay, deadlineTime, maxSubmitters, mTags) -> do
|
||||||
-- @TODO for the time being hardcoded
|
-- @TODO for the time being hardcoded
|
||||||
Just challengeEnt <- runDB $ getBy $ UniqueName "petite-difference-challenge2"
|
Just challengeEnt <- runDB $ getBy $ UniqueName "petite-difference-challenge2"
|
||||||
|
|
||||||
achievementId <- runDB $ insert $ Achievement name (entityKey challengeEnt) description (UTCTime { utctDay = deadlineDay, utctDayTime = timeOfDayToTime deadlineTime }) maxSubmitters
|
achievementId <- runDB $ insert $ Achievement name (entityKey challengeEnt) points description (UTCTime { utctDay = deadlineDay, utctDayTime = timeOfDayToTime deadlineTime }) maxSubmitters
|
||||||
|
|
||||||
tids <- runDB $ tagsAsTextToTagIds mTags
|
tids <- runDB $ tagsAsTextToTagIds mTags
|
||||||
|
|
||||||
@ -53,12 +53,14 @@ achievementsTable :: Table.Table App (Entity Achievement)
|
|||||||
achievementsTable = mempty
|
achievementsTable = mempty
|
||||||
++ Table.text "achievement" (\(Entity _ achievement) -> achievementName achievement)
|
++ Table.text "achievement" (\(Entity _ achievement) -> achievementName achievement)
|
||||||
++ Table.text "description" (\(Entity _ achievement) -> (fromMaybe (""::Text) (achievementDescription achievement)))
|
++ Table.text "description" (\(Entity _ achievement) -> (fromMaybe (""::Text) (achievementDescription achievement)))
|
||||||
|
++ Table.int "points" (\(Entity _ achievement) -> achievementPoints achievement)
|
||||||
++ timestampCell "deadline" (\(Entity _ achievement) -> achievementDeadline achievement)
|
++ timestampCell "deadline" (\(Entity _ achievement) -> achievementDeadline achievement)
|
||||||
|
|
||||||
achievementForm :: Form (Text, Maybe Text, Day, TimeOfDay, Maybe Int, Maybe Text)
|
achievementForm :: Form (Text, Maybe Text, Int, Day, TimeOfDay, Maybe Int, Maybe Text)
|
||||||
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 dayField (bfs MsgAchievementDeadlineDay) Nothing
|
<*> areq dayField (bfs MsgAchievementDeadlineDay) Nothing
|
||||||
<*> areq timeFieldTypeTime (bfs MsgAchievementDeadlineTime) Nothing
|
<*> areq timeFieldTypeTime (bfs MsgAchievementDeadlineTime) Nothing
|
||||||
<*> aopt intField (bfs MsgAchievementMaxWinners) Nothing
|
<*> aopt intField (bfs MsgAchievementMaxWinners) Nothing
|
||||||
|
@ -86,6 +86,7 @@ SubmissionTag
|
|||||||
Achievement
|
Achievement
|
||||||
name Text
|
name Text
|
||||||
challenge ChallengeId
|
challenge ChallengeId
|
||||||
|
points Int
|
||||||
description Text Maybe
|
description Text Maybe
|
||||||
deadline UTCTime
|
deadline UTCTime
|
||||||
maxWinners Int Maybe
|
maxWinners Int Maybe
|
||||||
|
@ -40,3 +40,4 @@ AchievementDeadlineTime: achievement deadline hour
|
|||||||
AchievementMaxWinners: maximum number of submitters
|
AchievementMaxWinners: maximum number of submitters
|
||||||
AchievementTags: tags required for an achievement
|
AchievementTags: tags required for an achievement
|
||||||
Achievements: achievements
|
Achievements: achievements
|
||||||
|
AchievementPoints: points
|
||||||
|
Loading…
Reference in New Issue
Block a user