2015-04-04 04:46:33 +00:00
|
|
|
module Handler.Home where
|
|
|
|
|
|
|
|
import Import
|
|
|
|
import qualified Text.Read as R
|
2015-04-16 00:51:08 +00:00
|
|
|
import Data.Maybe
|
2015-04-04 04:46:33 +00:00
|
|
|
|
|
|
|
-- This is a handler function for the GET request method on the HomeR
|
|
|
|
-- resource pattern. All of your resource patterns are defined in
|
|
|
|
-- config/routes
|
|
|
|
--
|
|
|
|
-- The majority of the code you will write in Yesod lives in these handler
|
|
|
|
-- functions. You can spread them across multiple files if you are so
|
|
|
|
-- inclined, or create a single monolithic file.
|
|
|
|
getHomeR :: Handler Html
|
|
|
|
getHomeR = do
|
|
|
|
beverages <- runDB $ selectList [BeverageAmount !=. 0] [Desc BeverageIdent]
|
|
|
|
time <- liftIO getCurrentTime
|
2015-07-22 05:08:59 +00:00
|
|
|
secs <- return $ (R.read $ formatTime defaultTimeLocale "%s" time) - 2592000
|
2015-04-04 04:46:33 +00:00
|
|
|
users <- runDB $ selectList [UserTimestamp >=. secs] [Asc UserIdent]
|
|
|
|
defaultLayout $ do
|
|
|
|
$(widgetFile "home")
|
|
|
|
|
|
|
|
postHomeR :: Handler Html
|
|
|
|
postHomeR = do
|
|
|
|
error "Not yet implemented"
|
|
|
|
|
|
|
|
getReactivateR :: Handler Html
|
|
|
|
getReactivateR = do
|
2015-04-08 16:02:33 +00:00
|
|
|
time <- liftIO getCurrentTime
|
2015-07-21 07:15:09 +00:00
|
|
|
secs <- return $ (R.read $ formatTime defaultTimeLocale "%s" time) - 2592000
|
2015-04-08 16:02:33 +00:00
|
|
|
users <- runDB $ selectList [UserTimestamp <. secs] [Asc UserIdent]
|
2015-04-04 04:46:33 +00:00
|
|
|
defaultLayout $ do
|
|
|
|
$(widgetFile "reactivate")
|
|
|
|
|
|
|
|
getUserReactivateR :: UserId -> Handler Html
|
|
|
|
getUserReactivateR uId = do
|
|
|
|
mUser <- runDB $ get uId
|
|
|
|
case mUser of
|
|
|
|
Just user -> do
|
|
|
|
time <- liftIO getCurrentTime
|
|
|
|
secs <- return $ R.read $ formatTime defaultTimeLocale "%s" time
|
|
|
|
runDB $ update uId [UserTimestamp =. secs]
|
2015-04-09 22:40:58 +00:00
|
|
|
setMessageI MsgUserReactivated
|
2015-04-04 04:46:33 +00:00
|
|
|
redirect $ HomeR
|
|
|
|
Nothing -> do
|
2015-04-09 22:40:58 +00:00
|
|
|
setMessageI MsgUserUnknown
|
2015-04-04 04:46:33 +00:00
|
|
|
redirect $ HomeR
|