diff options
author | Clint Adams <clint@softwarefreedom.org> | 2013-10-24 15:34:15 -0400 |
---|---|---|
committer | Clint Adams <clint@softwarefreedom.org> | 2013-10-24 17:39:13 -0400 |
commit | 515338784b8fc2fb5435ee4e061c092ff754d6cf (patch) | |
tree | ceb2c2660cacaa3b90a80836a9f1e0dd8941ffa2 /Handler/User.hs | |
parent | 1725e252b7bd6bec9faecb0249961343bb27afb0 (diff) |
Use newer persistent and newer Yesod
Diffstat (limited to 'Handler/User.hs')
-rw-r--r-- | Handler/User.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Handler/User.hs b/Handler/User.hs index e89b365..3d81f20 100644 --- a/Handler/User.hs +++ b/Handler/User.hs @@ -9,7 +9,7 @@ import Data.Time.Clock (getCurrentTime, UTCTime, utctDay) import Yesod.Auth (maybeAuth) import Yesod.Form.Jquery (jqueryDayField, def) -getUserR :: UserId -> Handler RepHtml +getUserR :: UserId -> Handler Html getUserR cid = do user <- runDB $ get404 cid ma <- maybeAuth @@ -27,11 +27,11 @@ getUserR cid = do employments <- runDB $ selectList [EmploymentUser ==. cid] [Asc EmploymentStartDate] (formWidget, formEnctype) <- generateFormPost (timeEntryForm cid cats) defaultLayout $ do - aDomId <- lift newIdent + aDomId <- newIdent (setTitle . toHtml) ("Time entries for " `T.append` username) $(widgetFile "userpage") -postUserR :: UserId -> Handler RepHtml +postUserR :: UserId -> Handler Html postUserR cid = do user <- runDB $ get404 cid ma <- maybeAuth @@ -53,11 +53,11 @@ postUserR cid = do entries <- runDB $ getEntriesForPage cid pageNumber defaultLayout $ do - aDomId <- lift newIdent + aDomId <- newIdent (setTitle . toHtml) ("Entry submitted for " `T.append` username) $(widgetFile "userpage") -timeEntryAForm :: UTCTime -> [(Text,TimeCategoryId)] -> UserId -> AForm App App TimeEntry +timeEntryAForm :: UTCTime -> [(Text,TimeCategoryId)] -> UserId -> AForm Handler TimeEntry timeEntryAForm ct cats uid = TimeEntry <$> pure uid <*> areq (selectFieldList cats) "category" Nothing @@ -66,17 +66,17 @@ timeEntryAForm ct cats uid = TimeEntry <*> areq textField "note" Nothing <*> pure ct -timeEntryForm :: UserId -> [(Text,TimeCategoryId)] -> Html -> MForm App App (FormResult TimeEntry, Widget) +timeEntryForm :: UserId -> [(Text,TimeCategoryId)] -> Html -> MForm Handler (FormResult TimeEntry, Widget) timeEntryForm u c h = do ct <- liftIO getCurrentTime renderDivs (timeEntryAForm ct c u) h -getEntriesForPage :: UserId -> Int -> YesodDB App App [(TimeCategoryId, TimeCategory, Text, Text, Text)] +-- getEntriesForPage :: UserId -> Int -> YesodDB m [(TimeCategoryId, TimeCategory, Text, Text, Text)] getEntriesForPage uid pageNumber = do entries <- selectList [TimeEntryUser ==. uid] [Desc TimeEntryTimestamp, LimitTo 25, OffsetBy ((pageNumber - 1) * 25)] mapM (\(Entity _ e) -> cat (timeEntryCategory e) >>= \x -> return (timeEntryCategory e, x, hours e, day e, timeEntryNote e)) entries where - cat :: TimeCategoryId -> YesodDB App App TimeCategory + -- cat :: TimeCategoryId -> YesodDB Handler TimeCategory cat y = do x <- getJust y return x day :: TimeEntry -> Text @@ -84,7 +84,7 @@ getEntriesForPage uid pageNumber = do hours :: TimeEntry -> Text hours = T.pack . show . timeEntryHours -pagePosition :: UserId -> GHandler App App (Int, Int) +pagePosition :: UserId -> Handler (Int, Int) pagePosition uid = do pageNumber <- fmap (either (const 1) id . fmap fst . fromMaybe (Right (1,"")) . fmap decimal) (lookupGetParam "page") cnt <- runDB $ count [TimeEntryUser ==. uid] |