diff --git a/Handler/AdminProfileSettings.hs b/Handler/AdminProfileSettings.hs index f51ba7e..e9af6ea 100644 --- a/Handler/AdminProfileSettings.hs +++ b/Handler/AdminProfileSettings.hs @@ -24,6 +24,30 @@ getAdminProfilesR = do setMessage "You must be logged in" redirect $ LoginR +getAdminUserAlbumsR :: UserId -> Handler Html +getAdminUserAlbumsR ownerId = do + msu <- lookupSession "userId" + case msu of + Just tempUserId -> do + userId <- return $ getUserIdFromText tempUserId + user <- runDB $ getJust userId + case userAdmin user of + True -> do + tempOwner <- runDB $ get ownerId + case tempOwner of + Just owner -> do + albums <- runDB $ selectList [AlbumOwner ==. ownerId] [Desc AlbumTitle] + defaultLayout $ do + $(widgetFile "adminUserAlbums") + Nothing -> do + setMessage "This user does not exist" + redirect $ AdminR + False -> do + setMessage "You are no admin" + redirect $ HomeR + Nothing -> do + setMessage "You must be kogged in" + redirect $ LoginR getAdminProfileSettingsR :: UserId -> Handler Html getAdminProfileSettingsR ownerId = do diff --git a/config/routes b/config/routes index 21d197c..7ee5260 100644 --- a/config/routes +++ b/config/routes @@ -25,6 +25,7 @@ /admin AdminR GET /admin/profile AdminProfilesR GET /admin/profile/#UserId AdminProfileSettingsR GET POST +/admin/profile/#UserId/albums AdminUserAlbumsR GET /admin/profile/#UserId/delete AdminProfileDeleteR GET /admin/album AdminAlbumsR GET /admin/album/#AlbumId AdminAlbumSettingsR GET POST diff --git a/templates/adminProfileSettings.hamlet b/templates/adminProfileSettings.hamlet index 289f456..5fa4408 100644 --- a/templates/adminProfileSettings.hamlet +++ b/templates/adminProfileSettings.hamlet @@ -12,6 +12,6 @@ $newline always