diff --git a/Foundation.hs b/Foundation.hs index 7dd74f0..1443d69 100755 --- a/Foundation.hs +++ b/Foundation.hs @@ -167,6 +167,7 @@ instance Yesod App where authRoute _ = Just $ AuthR LoginR isAuthorized AdminR _ = getAdminAuth + isAuthorized AdminRepopThumbsR _ = getAdminAuth isAuthorized AdminProfilesR _ = getAdminAuth isAuthorized (AdminProfileSettingsR _) _ = getAdminAuth isAuthorized (AdminUserAlbumsR _) _ = getAdminAuth diff --git a/Handler/Admin.hs b/Handler/Admin.hs index 91f66e5..c5f3bdb 100755 --- a/Handler/Admin.hs +++ b/Handler/Admin.hs @@ -17,6 +17,7 @@ module Handler.Admin where import Import +import Data.List (tail) import Handler.Commons -- import Database.Bloodhound @@ -31,3 +32,21 @@ getAdminR = do Left (errorMsg, route) -> do setMessage errorMsg redirect route + +getAdminRepopThumbsR :: Handler Html +getAdminRepopThumbsR = do + adminCheck <- loginIsAdmin + case adminCheck of + Right _ -> do + media <- runDB $ selectList [] [Asc MediumId] + mapM_ (\(Entity _ m) -> generateThumbs + (tail $ mediumPath m) + (mediumOwner m) + (mediumAlbum m) + (mediumMime m) + ) media + setMessage "Repopulation successfull" + redirect AdminR + Left (emsg, route) -> do + setMessage emsg + redirect route diff --git a/config/routes b/config/routes index 352d5d6..bfbc2ea 100755 --- a/config/routes +++ b/config/routes @@ -48,6 +48,7 @@ /profile/#UserId/delete ProfileDeleteR GET POST /admin AdminR GET +/admin/repop AdminRepopThumbsR GET /admin/profile AdminProfilesR GET /admin/profile/#UserId AdminProfileSettingsR GET POST /admin/profile/#UserId/albums AdminUserAlbumsR GET diff --git a/templates/adminBase.hamlet b/templates/adminBase.hamlet index 2a1820f..3d86879 100755 --- a/templates/adminBase.hamlet +++ b/templates/adminBase.hamlet @@ -21,6 +21,10 @@ $newline always

Comments +

+

+ Repopulate Thumbnails +