This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
formAv :: Form Avaliacao | |
formAv = renderDivs $ Avaliacao <$> | |
areq intField "Nota" Nothing <*> | |
pure kludge <*> | |
areq (selectField lv) "Livro:" Nothing <*> | |
areq textField "Avaliação: " Nothing | |
kludge = case us of | |
Just (Entity pid user) -> pid | |
Nothing -> redirect LoginR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alunos = [{nome:"Nilmar",notas:[2.5,6,6]},{nome:"Gustavo",notas:[6,4.5,7]},{nome:"Alexandre",notas:[10,10,0]},{nome:"Lionel Messi",notas:[5.9,5.9,5.9]}] | |
aprovados = alunos.filter(function(x) { | |
return (x.notas.sort(function(a, b) { | |
return a - b; | |
}).splice(0, 2).reduce(function(y, z) { | |
return y + z; | |
}) / 2) >= 6; | |
}); | |
console.log(aprovados); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
patchAgendamento :: Handler Value | |
patchAgendamento = do | |
horarioNovo <- requireJsonBody :: Handler UTCTime | |
valores <- runDB $ selectList [] [Asc AgendamentoHorario] | |
runDB $ mapM_ (\chave -> update chave [AgendamentoHorario =. hoarioNovo]) valores | |
sendStatusJSON noContent204 $ object emptyObject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runDB $ do | |
prods <- selectList [] [] | |
forns <- mapM (get . produtoFornecedorId . entityVal) prods | |
return . zip prods $ catMaybes forns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Foundation where | |
import Yesod | |
import Yesod.Static | |
import Yesod.Auth | |
import Yesod.Auth.Email as YAE | |
import Yesod.Auth.GoogleEmail2 as GE2 | |
import Yesod.Auth.Facebook.ServerSide as YAF | |
import Yesod.Facebook | |
import Control.Applicative ((<$>), (<*>)) |