diff --git a/Application.hs b/Application.hs index 75fc564..be31137 100644 --- a/Application.hs +++ b/Application.hs @@ -43,6 +43,7 @@ import Handler.ProfileSettings import Handler.ProfileDelete import Handler.Admin import Handler.AdminProfileSettings +import Handler.AdminAlbumSettings -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the diff --git a/Handler/AdminAlbumSettings.hs b/Handler/AdminAlbumSettings.hs new file mode 100644 index 0000000..7de9bde --- /dev/null +++ b/Handler/AdminAlbumSettings.hs @@ -0,0 +1,31 @@ +module Handler.AdminAlbumSettings where + +import Import + +getAdminAlbumsR :: Handler Html +getAdminAlbumsR = do + msu <- lookupSession "userId" + case msu of + Just tempUserId -> do + userId <- return $ getUserIdFromText tempUserId + user <- runDB $ getJust userId + case userAdmin user of + True -> do + albums <- runDB $ selectList [] [Desc AlbumTitle] + defaultLayout $ do + $(widgetFile "adminAlbums") + False -> do + setMessage "You are no admin" + redirect $ HomeR + Nothing -> do + setMessage "You must be logged in" + redirect $ LoginR + +getAdminAlbumSettingsR :: AlbumId -> Handler Html +getAdminAlbumSettingsR = error "Not yet implemented: getAdminAlbumSettingsR" + +postAdminAlbumSettingsR :: AlbumId -> Handler Html +postAdminAlbumSettingsR = error "Not yet implemented: postAdminAlbumSettingsR" + +getAdminAlbumDeleteR :: AlbumId -> Handler Html +getAdminAlbumDeleteR albumId = error "Not yet implemented: getAdminAlbumDeleteR" diff --git a/Handler/AdminProfileSettings.hs b/Handler/AdminProfileSettings.hs index 3cf80e7..f51ba7e 100644 --- a/Handler/AdminProfileSettings.hs +++ b/Handler/AdminProfileSettings.hs @@ -5,8 +5,8 @@ import qualified Data.Text as T import System.Directory import System.FilePath -getAdminProfiles :: Handler Html -getAdminProfiles = do +getAdminProfilesR :: Handler Html +getAdminProfilesR = do msu <- lookupSession "userId" case msu of Just tempUserId -> do diff --git a/config/routes b/config/routes index 84c0d65..21d197c 100644 --- a/config/routes +++ b/config/routes @@ -23,6 +23,9 @@ /profile/#UserId/settings ProfileSettingsR GET POST /profile/#UserId/delete ProfileDeleteR GET POST /admin AdminR GET -/admin/profile AdminProfiles GET +/admin/profile AdminProfilesR GET /admin/profile/#UserId AdminProfileSettingsR GET POST /admin/profile/#UserId/delete AdminProfileDeleteR GET +/admin/album AdminAlbumsR GET +/admin/album/#AlbumId AdminAlbumSettingsR GET POST +/admin/album/#AlbumId/delete AdminAlbumDeleteR GET diff --git a/eidolon.cabal b/eidolon.cabal index dca4e2d..50d5fa8 100644 --- a/eidolon.cabal +++ b/eidolon.cabal @@ -36,6 +36,7 @@ library Handler.ProfileDelete Handler.Admin Handler.AdminProfileSettings + Handler.AdminAlbumSettings if flag(dev) || flag(library-only) cpp-options: -DDEVELOPMENT diff --git a/templates/adminAlbums.hamlet b/templates/adminAlbums.hamlet new file mode 100644 index 0000000..a4e2975 --- /dev/null +++ b/templates/adminAlbums.hamlet @@ -0,0 +1,10 @@ +$newline always +

Albums + +$if null albums + There are no albums yet +$else + $forall (Entity aId a) <- albums +