changed album logic
This commit is contained in:
parent
8b6d75a997
commit
72e4f16125
1 changed files with 21 additions and 15 deletions
|
@ -2,18 +2,24 @@ module Handler.Album where
|
|||
|
||||
import Import
|
||||
|
||||
getAlbumR :: UserId -> AlbumId -> Handler Html
|
||||
getAlbumR ownerId albumId = do
|
||||
owner <- runDB $ getJust ownerId
|
||||
ownerName <- lift $ pure $ userName owner
|
||||
album <- runDB $ getJust albumId
|
||||
msu <- lookupSession "userId"
|
||||
presence <- case msu of
|
||||
Just tempUserId -> do
|
||||
userId <- lift $ pure $ getUserIdFromText tempUserId
|
||||
return (userId == ownerId)
|
||||
Nothing ->
|
||||
return False
|
||||
media <- mapM (\a -> runDB $ getJust a) (albumContent album)
|
||||
defaultLayout $ do
|
||||
$(widgetFile "album")
|
||||
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
|
||||
return (userId == ownerId)
|
||||
Nothing ->
|
||||
return False
|
||||
media <- mapM (\a -> runDB $ getJust a) (albumContent album)
|
||||
defaultLayout $ do
|
||||
$(widgetFile "album")
|
||||
Nothing -> do
|
||||
setMessage "This album does not exist"
|
||||
redirect $ HomeR
|
||||
|
|
Loading…
Reference in a new issue