starred challenges

This commit is contained in:
Filip Gralinski 2018-01-18 09:21:21 +01:00
parent ae2d28ceff
commit 828ae71006
6 changed files with 17 additions and 3 deletions

View File

@ -92,7 +92,8 @@ addChallenge name publicRepoId privateRepoId chan = do
challengeTitle=(T.pack $ title), challengeTitle=(T.pack $ title),
challengeDescription=(T.pack $ description), challengeDescription=(T.pack $ description),
challengeStamp=time, challengeStamp=time,
challengeImage=mImage } challengeImage=mImage,
challengeStarred=Just False}
updateTests challengeId chan updateTests challengeId chan
return () return ()

View File

@ -3,6 +3,7 @@ module Handler.Home where
import Import import Import
import Handler.Shared import Handler.Shared
import Handler.ListChallenges
-- This is a handler function for the GET request method on the HomeR -- This is a handler function for the GET request method on the HomeR
-- resource pattern. All of your resource patterns are defined in -- resource pattern. All of your resource patterns are defined in
@ -15,6 +16,9 @@ getHomeR :: Handler Html
getHomeR = do getHomeR = do
maybeUser <- maybeAuth maybeUser <- maybeAuth
master <- getYesod master <- getYesod
starredChallenges <- runDB $ selectList [ChallengeStarred ==. Just True] [Asc ChallengeStarred, Desc ChallengeStamp]
let maybeLocalId = case maybeUser of let maybeLocalId = case maybeUser of
Just user -> userLocalId $ entityVal user Just user -> userLocalId $ entityVal user
Nothing -> Nothing Nothing -> Nothing

View File

@ -4,7 +4,7 @@ import Import
getListChallengesR :: Handler Html getListChallengesR :: Handler Html
getListChallengesR = do getListChallengesR = do
challenges <- runDB $ selectList [] [Desc ChallengeStamp] challenges <- runDB $ selectList [] [Asc ChallengeStarred, Desc ChallengeStamp]
defaultLayout $ do defaultLayout $ do
setTitle "List challenges" setTitle "List challenges"
$(widgetFile "list-challenges") $(widgetFile "list-challenges")

View File

@ -37,6 +37,7 @@ Challenge
description Text description Text
stamp UTCTime default=now() stamp UTCTime default=now()
image ByteString Maybe image ByteString Maybe
starred Bool Maybe
Test Test
challenge ChallengeId challenge ChallengeId
metric Metric metric Metric

View File

@ -29,3 +29,9 @@
<strong>How to log in?</strong> If you already have an account, just click <a href="@{AuthR LoginR}">log in</a>. Otherwise, please get in touch with the site admin#{contactEmailLabel master}. <strong>How to log in?</strong> If you already have an account, just click <a href="@{AuthR LoginR}">log in</a>. Otherwise, please get in touch with the site admin#{contactEmailLabel master}.
<p class="text-muted text-right"><sup>*</sup>Disclaimer: Gonito is neither affiliated with nor endorsed by <a href="https://www.kaggle.com">Kaggle</a>. <p class="text-muted text-right"><sup>*</sup>Disclaimer: Gonito is neither affiliated with nor endorsed by <a href="https://www.kaggle.com">Kaggle</a>.
$if not (null starredChallenges)
<h2>Challenges
^{listChallengesCore starredChallenges}
<p>… and <a href="@{ListChallengesR}">many more</a>!

View File

@ -1,6 +1,8 @@
$forall (Entity challengeId challenge) <- challenges $forall (Entity challengeId challenge) <- challenges
<div class="panel panel-success"> <div class="panel panel-success">
<div class="panel-heading"><a .challenge-link href="@{ShowChallengeR (challengeName challenge)}">#{challengeTitle challenge}</a> <div class="panel-heading"><a .challenge-link href="@{ShowChallengeR (challengeName challenge)}">#{challengeTitle challenge}</a>
$if challengeStarred challenge == Just True
\ <span class="glyphicon glyphicon-star-empty"></span>
$if isJust (challengeImage challenge) $if isJust (challengeImage challenge)
<div class="panel-body" style="background-image:url(@{ChallengeImageR challengeId}); background-color:lightgrey; background-blend-mode:screen;background-size: 100%;">#{challengeDescription challenge} <div class="panel-body" style="background-image:url(@{ChallengeImageR challengeId}); background-color:lightgrey; background-blend-mode:screen;background-size: 100%;">#{challengeDescription challenge}
$else $else