From 515338784b8fc2fb5435ee4e061c092ff754d6cf Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Thu, 24 Oct 2013 15:34:15 -0400 Subject: Use newer persistent and newer Yesod --- Handler/User.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Handler/User.hs') 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] -- cgit v1.2.3