2014-08-18 01:09:37 +00:00
|
|
|
module Handler.Album where
|
|
|
|
|
|
|
|
import Import
|
2014-09-24 21:03:18 +00:00
|
|
|
import qualified Data.Text as T
|
2014-08-18 01:09:37 +00:00
|
|
|
|
2014-08-18 04:07:10 +00:00
|
|
|
getAlbumR :: AlbumId -> Handler Html
|
|
|
|
getAlbumR albumId = do
|
|
|
|
tempAlbum <- runDB $ get albumId
|
|
|
|
case tempAlbum of
|
|
|
|
Just album -> do
|
|
|
|
ownerId <- return $ albumOwner album
|
|
|
|
owner <- runDB $ getJust ownerId
|
|
|
|
ownerName <- return $ userName owner
|
|
|
|
msu <- lookupSession "userId"
|
|
|
|
presence <- case msu of
|
|
|
|
Just tempUserId -> do
|
|
|
|
userId <- return $ getUserIdFromText tempUserId
|
2014-12-06 03:39:24 +00:00
|
|
|
return $ (userId == ownerId) || (userId `elem` (albumShares album))
|
2014-08-18 04:07:10 +00:00
|
|
|
Nothing ->
|
2014-12-06 03:39:24 +00:00
|
|
|
return False
|
2014-08-18 11:17:54 +00:00
|
|
|
-- media <- mapM (\a -> runDB $ getJust a) (albumContent album)
|
|
|
|
media <- runDB $ selectList [MediumAlbum ==. albumId] [Desc MediumTime]
|
2014-08-18 04:07:10 +00:00
|
|
|
defaultLayout $ do
|
2014-09-24 21:03:18 +00:00
|
|
|
setTitle $ toHtml ("Eidolon :: Album " `T.append` (albumTitle album))
|
2014-08-18 04:07:10 +00:00
|
|
|
$(widgetFile "album")
|
|
|
|
Nothing -> do
|
|
|
|
setMessage "This album does not exist"
|
|
|
|
redirect $ HomeR
|