yammat/Handler/Summary.hs

27 lines
701 B
Haskell
Raw Normal View History

2015-04-04 04:46:33 +00:00
module Handler.Summary where
import Import
2015-04-10 00:53:55 +00:00
import qualified Data.List as L
2015-04-07 14:30:06 +00:00
import Handler.Common
2015-04-04 04:46:33 +00:00
getSummaryR :: Handler Html
getSummaryR = do
2015-04-04 06:18:15 +00:00
master <- getYesod
2015-04-04 04:46:33 +00:00
bevs <- runDB $ selectList [] [Asc BeverageIdent]
defaultLayout $ do
$(widgetFile "summary")
2015-04-10 00:53:55 +00:00
getSummaryJsonR :: Handler RepJson
getSummaryJsonR = do
master <- getYesod
bevs <- runDB $ selectList [] [Asc BeverageIdent]
return $
repJson $ array $
map (\(Entity _ bev) ->
object [ "name" .= beverageIdent bev
, "value" .= beverageAmount bev
, "price" .= beveragePrice bev
, "currency" .= appCurrency (appSettings master)
]
) bevs