changed order of checks to better ordering
This commit is contained in:
parent
b4b09cde37
commit
61e94cfa91
1 changed files with 54 additions and 54 deletions
|
@ -26,9 +26,6 @@ getAdminAlbumsR = do
|
|||
|
||||
getAdminAlbumSettingsR :: AlbumId -> Handler Html
|
||||
getAdminAlbumSettingsR albumId = do
|
||||
tempAlbum <- runDB $ get albumId
|
||||
case tempAlbum of
|
||||
Just album -> do
|
||||
msu <- lookupSession "userId"
|
||||
case msu of
|
||||
Just tempUserId -> do
|
||||
|
@ -36,24 +33,24 @@ getAdminAlbumSettingsR albumId = do
|
|||
user <- runDB $ getJust userId
|
||||
case userAdmin user of
|
||||
True -> do
|
||||
tempAlbum <- runDB $ get albumId
|
||||
case tempAlbum of
|
||||
Just album -> do
|
||||
(adminAlbumSettingsWidget, enctype) <- generateFormPost $ adminAlbumSettingsForm album albumId
|
||||
defaultLayout $ do
|
||||
$(widgetFile "adminAlbumSet")
|
||||
Nothing -> do
|
||||
setMessage "This album does not exist"
|
||||
redirect $ AdminR
|
||||
False -> do
|
||||
setMessage "You must be admin"
|
||||
setMessage "You are no admin"
|
||||
redirect $ HomeR
|
||||
Nothing -> do
|
||||
setMessage "You must be logged in"
|
||||
redirect $ LoginR
|
||||
Nothing -> do
|
||||
setMessage "This album does not exist"
|
||||
redirect $ AdminR
|
||||
|
||||
postAdminAlbumSettingsR :: AlbumId -> Handler Html
|
||||
postAdminAlbumSettingsR albumId = do
|
||||
tempAlbum <- runDB $ get albumId
|
||||
case tempAlbum of
|
||||
Just album -> do
|
||||
msu <- lookupSession "userId"
|
||||
case msu of
|
||||
Just tempUserId -> do
|
||||
|
@ -61,6 +58,9 @@ postAdminAlbumSettingsR albumId = do
|
|||
user <- runDB $ getJust userId
|
||||
case userAdmin user of
|
||||
True -> do
|
||||
tempAlbum <- runDB $ get albumId
|
||||
case tempAlbum of
|
||||
Just album -> do
|
||||
((res, adminAlbumSettingsWidget), enctype) <- runFormPost $ adminAlbumSettingsForm album albumId
|
||||
case res of
|
||||
FormSuccess temp -> do
|
||||
|
@ -73,15 +73,15 @@ postAdminAlbumSettingsR albumId = do
|
|||
_ -> do
|
||||
setMessage "There was an error while changing the settings"
|
||||
redirect $ AdminAlbumSettingsR albumId
|
||||
Nothing -> do
|
||||
setMessage "This album does not exist"
|
||||
redirect $ AdminR
|
||||
False -> do
|
||||
setMessage "You must be admin"
|
||||
setMessage "You are no admin"
|
||||
redirect $ HomeR
|
||||
Nothing -> do
|
||||
setMessage "You must be logged in"
|
||||
redirect $ LoginR
|
||||
Nothing -> do
|
||||
setMessage "This album does not exist"
|
||||
redirect $ AdminR
|
||||
|
||||
adminAlbumSettingsForm :: Album -> AlbumId -> Form Album
|
||||
adminAlbumSettingsForm album albumId = renderDivs $ Album
|
||||
|
@ -96,9 +96,6 @@ adminAlbumSettingsForm album albumId = renderDivs $ Album
|
|||
|
||||
getAdminAlbumDeleteR :: AlbumId -> Handler Html
|
||||
getAdminAlbumDeleteR albumId = do
|
||||
tempAlbum <- runDB $ get albumId
|
||||
case tempAlbum of
|
||||
Just album -> do
|
||||
msu <- lookupSession "userId"
|
||||
case msu of
|
||||
Just tempUserId -> do
|
||||
|
@ -106,6 +103,9 @@ getAdminAlbumDeleteR albumId = do
|
|||
user <- runDB $ getJust userId
|
||||
case userAdmin user of
|
||||
True -> do
|
||||
tempAlbum <- runDB $ get albumId
|
||||
case tempAlbum of
|
||||
Just album -> do
|
||||
-- remove reference from owner
|
||||
ownerId <- return $ albumOwner album
|
||||
owner <- runDB $ getJust ownerId
|
||||
|
@ -120,12 +120,12 @@ getAdminAlbumDeleteR albumId = do
|
|||
-- outro
|
||||
setMessage "Album deleted successfully"
|
||||
redirect $ AdminR
|
||||
_ -> do
|
||||
Nothing -> do
|
||||
setMessage "This album dies not exist"
|
||||
redirect $ AdminR
|
||||
False -> do
|
||||
setMessage "You are no admin"
|
||||
redirect $ HomeR
|
||||
Nothing -> do
|
||||
setMessage "You must be logged in"
|
||||
redirect $ LoginR
|
||||
Nothing -> do
|
||||
setMessage "This Album does not exist"
|
||||
redirect $ AdminR
|
||||
|
|
Loading…
Reference in a new issue