admin interface for albums by user
This commit is contained in:
parent
61e94cfa91
commit
1498a83f0f
4 changed files with 36 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,6 +12,6 @@ $newline always
|
|||
<div class="right">
|
||||
<ul>
|
||||
<li>
|
||||
Albums of this user
|
||||
<a href=@{AdminUserAlbumsR ownerId}>Albums of this user
|
||||
<li>
|
||||
Media of this user
|
||||
|
|
10
templates/adminUserAlbums.hamlet
Normal file
10
templates/adminUserAlbums.hamlet
Normal 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}
|
Loading…
Reference in a new issue