more in admin interface
additionals
This commit is contained in:
parent
f5f2ac336d
commit
11e70530b3
9 changed files with 78 additions and 8 deletions
|
@ -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
|
||||
|
|
31
Handler/AdminAlbumSettings.hs
Normal file
31
Handler/AdminAlbumSettings.hs
Normal file
|
@ -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"
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -36,6 +36,7 @@ library
|
|||
Handler.ProfileDelete
|
||||
Handler.Admin
|
||||
Handler.AdminProfileSettings
|
||||
Handler.AdminAlbumSettings
|
||||
|
||||
if flag(dev) || flag(library-only)
|
||||
cpp-options: -DDEVELOPMENT
|
||||
|
|
10
templates/adminAlbums.hamlet
Normal file
10
templates/adminAlbums.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}
|
|
@ -3,3 +3,9 @@ $newline always
|
|||
|
||||
<p>
|
||||
Be careful with your actions here, every click will perform directly the advertised action.
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href=@{AdminProfilesR}>User profiles
|
||||
<li>
|
||||
<a href=@{AdminAlbumsR}>Albums
|
||||
|
|
10
templates/adminProfileSettings.cassius
Normal file
10
templates/adminProfileSettings.cassius
Normal file
|
@ -0,0 +1,10 @@
|
|||
.right
|
||||
float:right
|
||||
width:50%
|
||||
|
||||
.left
|
||||
float:left
|
||||
width:50%
|
||||
|
||||
footer
|
||||
clear:both
|
|
@ -1,9 +1,17 @@
|
|||
$newline always
|
||||
<h3>Profile settings
|
||||
|
||||
<form method="post" enctype=#{enctype}>
|
||||
^{adminProfileSetWidget}
|
||||
<div>
|
||||
<input type=submit value="Change settings">
|
||||
<div class="left">
|
||||
<form method="post" enctype=#{enctype}>
|
||||
^{adminProfileSetWidget}
|
||||
<div>
|
||||
<input type=submit value="Change settings">
|
||||
|
||||
<a href=@{AdminProfileDeleteR userId}>Delete user
|
||||
<a href=@{AdminProfileDeleteR userId}>Delete user
|
||||
|
||||
<div class="right">
|
||||
<ul>
|
||||
<li>
|
||||
Albums of this user
|
||||
<li>
|
||||
Media of this user
|
||||
|
|
Loading…
Reference in a new issue