From b50f892d32fe1dc4941043161cd46da61af86fb5 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Wed, 25 May 2016 07:24:34 +0000 Subject: [PATCH] Display group members in group page --- src/Vervis/Handler/Group.hs | 20 ++++++++++++++------ templates/group/one.hamlet | 10 +++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Vervis/Handler/Group.hs b/src/Vervis/Handler/Group.hs index c080b16..ebb4fd1 100644 --- a/src/Vervis/Handler/Group.hs +++ b/src/Vervis/Handler/Group.hs @@ -24,6 +24,7 @@ where import Prelude import Control.Monad.IO.Class (liftIO) +import Data.Maybe (fromMaybe) import Data.Time.Clock (getCurrentTime) import Database.Esqueleto import Text.Blaze.Html (Html) @@ -36,9 +37,9 @@ import Yesod.Persist.Core (runDB, getBy404) import Vervis.Form.Group import Vervis.Foundation import Vervis.Model -import Vervis.Model.Ident (ShrIdent) +import Vervis.Model.Ident (ShrIdent, shr2text) import Vervis.Settings (widgetFile) -import Vervis.Widget.Sharer (groupLinkW) +import Vervis.Widget.Sharer (groupLinkW, personLinkW) getGroupsR :: Handler Html getGroupsR = do @@ -80,8 +81,15 @@ getGroupNewR = do getGroupR :: ShrIdent -> Handler Html getGroupR shar = do - group <- runDB $ do - Entity sid _s <- getBy404 $ UniqueSharer shar - Entity _gid g <- getBy404 $ UniqueGroup sid - return g + (group, members) <- runDB $ do + Entity sid s <- getBy404 $ UniqueSharer shar + Entity gid _g <- getBy404 $ UniqueGroup sid + ms <- select $ from $ \ (member, person, sharer) -> do + where_ $ + member ^. GroupMemberGroup ==. val gid &&. + member ^. GroupMemberPerson ==. person ^. PersonId &&. + person ^. PersonIdent ==. sharer ^. SharerId + orderBy [asc $ sharer ^. SharerIdent] + return sharer + return (s, ms) defaultLayout $(widgetFile "group/one") diff --git a/templates/group/one.hamlet b/templates/group/one.hamlet index 91a0449..d537141 100644 --- a/templates/group/one.hamlet +++ b/templates/group/one.hamlet @@ -12,5 +12,13 @@ $# You should have received a copy of the CC0 Public Domain Dedication along $# with this software. If not, see $# . +

+ #{fromMaybe (shr2text $ sharerIdent group) $ sharerName group} +

- TODO list the group's members here, and later also roles etc. + Members: + +

    + $forall Entity _sid s <- members +
  • + ^{personLinkW s}