admin interface for albums by user

This commit is contained in:
nek0 2014-09-08 03:57:17 +02:00
parent 61e94cfa91
commit 1498a83f0f
4 changed files with 36 additions and 1 deletions

View file

@ -24,6 +24,30 @@ getAdminProfilesR = do
setMessage "You must be logged in" setMessage "You must be logged in"
redirect $ LoginR 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 :: UserId -> Handler Html
getAdminProfileSettingsR ownerId = do getAdminProfileSettingsR ownerId = do

View file

@ -25,6 +25,7 @@
/admin AdminR GET /admin AdminR GET
/admin/profile AdminProfilesR GET /admin/profile AdminProfilesR GET
/admin/profile/#UserId AdminProfileSettingsR GET POST /admin/profile/#UserId AdminProfileSettingsR GET POST
/admin/profile/#UserId/albums AdminUserAlbumsR GET
/admin/profile/#UserId/delete AdminProfileDeleteR GET /admin/profile/#UserId/delete AdminProfileDeleteR GET
/admin/album AdminAlbumsR GET /admin/album AdminAlbumsR GET
/admin/album/#AlbumId AdminAlbumSettingsR GET POST /admin/album/#AlbumId AdminAlbumSettingsR GET POST

View file

@ -12,6 +12,6 @@ $newline always
<div class="right"> <div class="right">
<ul> <ul>
<li> <li>
Albums of this user <a href=@{AdminUserAlbumsR ownerId}>Albums of this user
<li> <li>
Media of this user Media of this user

View file

@ -0,0 +1,10 @@
$newline always
<h3>Albums
$if null albums
There are no albums yet
$else
$forall (Entity aId a) <- albums
<ul>
<li>
<a href=@{AdminAlbumSettingsR aId}>#{albumTitle a}