Sharers page lists them, sharer page redirects to person or group

This commit is contained in:
fr33domlover 2016-06-06 13:34:23 +00:00
parent 174c44bfa4
commit 893d91acd8
2 changed files with 52 additions and 4 deletions

View file

@ -21,13 +21,40 @@ where
import Prelude import Prelude
import Control.Monad.Logger (logWarn)
import Data.Monoid ((<>))
import Database.Persist
import Text.Blaze.Html (Html) import Text.Blaze.Html (Html)
import Yesod.Core (defaultLayout)
import Yesod.Core.Handler (redirect, notFound)
import Yesod.Persist.Core (runDB, getBy404)
import Vervis.Foundation (Handler) import Vervis.Foundation
import Vervis.Model.Ident (ShrIdent) import Vervis.Model
import Vervis.Model.Ident (ShrIdent, shr2text)
import Vervis.Settings (widgetFile)
import Vervis.Widget.Sharer (sharerLinkW)
getSharersR :: Handler Html getSharersR :: Handler Html
getSharersR = error "TODO" getSharersR = do
sharers <- runDB $ selectList [] [Asc SharerIdent]
defaultLayout $(widgetFile "sharer/list")
getSharerR :: ShrIdent -> Handler Html getSharerR :: ShrIdent -> Handler Html
getSharerR shar = error "TODO" getSharerR shr = do
isperson <- runDB $ do
Entity sid _sharer <- getBy404 $ UniqueSharer shr
mp <- getBy $ UniquePersonIdent sid
case mp of
Just _ -> return $ Just True
Nothing -> do
mg <- getBy $ UniqueGroup sid
case mg of
Just _ -> return $ Just False
Nothing -> return Nothing
case isperson of
Nothing -> do
$logWarn $ "Found non-person non-group sharer: " <> shr2text shr
notFound
Just True -> redirect $ PersonR shr
Just False -> redirect $ GroupR shr

View file

@ -0,0 +1,21 @@
$# This file is part of Vervis.
$#
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
$#
$# ♡ Copying is an act of love. Please copy, reuse and share.
$#
$# The author(s) have dedicated all copyright and related and neighboring
$# rights to this software to the public domain worldwide. This software is
$# distributed without any warranty.
$#
$# You should have received a copy of the CC0 Public Domain Dedication along
$# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
<p>
These are the people and groups registered in this Vervis instance.
<ul>
$forall Entity _ sharer <- sharers
<li>
^{sharerLinkW sharer}