Project page lists project's repos

This commit is contained in:
fr33domlover 2016-05-14 11:36:45 +00:00
parent 4d410cf1f7
commit ee9b40d466
3 changed files with 57 additions and 22 deletions

View file

@ -21,23 +21,35 @@ module Vervis.Handler.Project
) )
where where
import Vervis.Import hiding ((==.)) import Prelude
--import Prelude
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Database.Persist
import Text.Blaze.Html (Html)
import Yesod.Auth (requireAuth)
import Yesod.Core (defaultLayout)
import Yesod.Core.Handler (redirect, setMessage)
import Yesod.Form.Functions (runFormPost)
import Yesod.Form.Types (FormResult (..))
import Yesod.Persist.Core (runDB, getBy404)
import qualified Database.Esqueleto as E
import Text.Blaze.Html (toHtml)
import Database.Esqueleto
--import Model
--import Yesod.Core (Handler)
import Vervis.Form.Project import Vervis.Form.Project
import Vervis.Foundation
import Vervis.Model
import Vervis.Model.Repo
import Vervis.Settings
getProjectsR :: Text -> Handler Html getProjectsR :: Text -> Handler Html
getProjectsR ident = do getProjectsR ident = do
projects <- runDB $ select $ from $ \ (sharer, project) -> do projects <- runDB $ E.select $ E.from $ \ (sharer, project) -> do
where_ $ E.where_ $
sharer ^. SharerIdent ==. val ident &&. sharer E.^. SharerIdent E.==. E.val ident E.&&.
sharer ^. SharerId ==. project ^. ProjectSharer sharer E.^. SharerId E.==. project E.^. ProjectSharer
orderBy [asc $ project ^. ProjectIdent] E.orderBy [E.asc $ project E.^. ProjectIdent]
return $ project ^. ProjectIdent return $ project E.^. ProjectIdent
defaultLayout $(widgetFile "project/list") defaultLayout $(widgetFile "project/list")
postProjectsR :: Text -> Handler Html postProjectsR :: Text -> Handler Html
@ -65,9 +77,10 @@ getProjectNewR ident = do
defaultLayout $(widgetFile "project/new") defaultLayout $(widgetFile "project/new")
getProjectR :: Text -> Text -> Handler Html getProjectR :: Text -> Text -> Handler Html
getProjectR user proj = do getProjectR shar proj = do
project <- runDB $ do (project, repos) <- runDB $ do
Entity sid _s <- getBy404 $ UniqueSharerIdent user Entity sid _s <- getBy404 $ UniqueSharerIdent shar
Entity _pid p <- getBy404 $ UniqueProject proj sid Entity pid p <- getBy404 $ UniqueProject proj sid
return p rs <- selectList [RepoProject ==. Just pid] [Asc RepoIdent]
return (p, rs)
defaultLayout $(widgetFile "project/one") defaultLayout $(widgetFile "project/one")

View file

@ -15,6 +15,6 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<p>These are projects shared by #{ident}. <p>These are projects shared by #{ident}.
<ul> <ul>
$forall Value project <- projects $forall E.Value project <- projects
<li> <li>
<a href=@{ProjectR ident project}>#{project} <a href=@{ProjectR ident project}>#{project}

View file

@ -12,7 +12,7 @@ $# You should have received a copy of the CC0 Public Domain Dedication along
$# with this software. If not, see $# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>. $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<p>This is the project page for <b>#{proj}</b>, shared by <b>#{user}</b>. <p>This is the project page for <b>#{proj}</b>, shared by <b>#{shar}</b>.
<ul> <ul>
<li> <li>
@ -20,6 +20,28 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<li> <li>
Description: #{fromMaybe "(none)" $ projectDesc project} Description: #{fromMaybe "(none)" $ projectDesc project}
<li> <li>
TODO list the project's repos here, or link to a separate page that does <a href=@{TicketsR shar proj}>Tickets
<li>
<a href=@{TicketsR user proj}>Tickets <h2>Repos
$if null repos
<p>This project doesnt contain repositories.
$else
<table>
<tr>
<th>Name
<th>VCS
<th>Description
$forall Entity _ repository <- repos
<tr>
<td>
<a href=@{RepoR shar $ repoIdent repository}>#{repoIdent repository}
<td>
$case repoVcs repository
$of VCSDarcs
Darcs
$of VCSGit
Git
<td>
$maybe desc <- repoDesc repository
#{desc}