eidolon/Handler/Medium.hs

31 lines
925 B
Haskell
Raw Normal View History

2014-08-18 04:06:16 +00:00
module Handler.Medium where
import Import
import Data.Time
2014-09-24 21:03:18 +00:00
import qualified Data.Text as T
2014-08-18 04:06:16 +00:00
import System.Locale
getMediumR :: MediumId -> Handler Html
getMediumR mediumId = do
tempMedium <- runDB $ get mediumId
case tempMedium of
Just medium -> do
ownerId <- return $ mediumOwner medium
owner <- runDB $ getJust ownerId
ownerName <- return $ userName owner
2014-09-05 19:00:03 +00:00
albumId <- return $ mediumAlbum medium
album <- runDB $ getJust albumId
2014-08-18 04:06:16 +00:00
msu <- lookupSession "userId"
presence <- case msu of
Just tempUserId -> do
userId <- return $ getUserIdFromText tempUserId
return (userId == ownerId)
Nothing ->
return False
defaultLayout $ do
2014-09-24 21:03:18 +00:00
setTitle $ toHtml ("Eidolon :: Medium " `T.append` (mediumTitle medium))
2014-08-18 04:06:16 +00:00
$(widgetFile "medium")
Nothing -> do
setMessage "This image does not exist"
redirect $ HomeR