From 11d4a955d847e16dba80a6ee050252783b5bff97 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Tue, 7 Jun 2016 16:31:55 +0000 Subject: [PATCH] Per-ticket list of claim requests with full info --- config/models | 2 +- config/routes | 121 ++++++++++---------- src/Vervis/Foundation.hs | 9 +- src/Vervis/Handler/Ticket.hs | 28 ++++- templates/personal-overview.hamlet | 2 +- templates/project/claim-request/list.hamlet | 30 +++++ templates/project/one.hamlet | 2 +- templates/ticket/claim-request/list.hamlet | 11 +- templates/ticket/one.hamlet | 3 + 9 files changed, 129 insertions(+), 79 deletions(-) create mode 100644 templates/project/claim-request/list.hamlet diff --git a/config/models b/config/models index c087a28..b1f4c84 100644 --- a/config/models +++ b/config/models @@ -135,7 +135,7 @@ Ticket TicketClaimRequest person PersonId ticket TicketId - message Text + message Text -- Assume this is Pandoc Markdown created UTCTime UniqueTicketClaimRequest person ticket diff --git a/config/routes b/config/routes index 7dc7011..f0b19af 100644 --- a/config/routes +++ b/config/routes @@ -32,80 +32,81 @@ -- People -- ---------------------------------------------------------------------------- -/s SharersR GET -/s/#ShrIdent SharerR GET +/s SharersR GET +/s/#ShrIdent SharerR GET -/p PeopleR GET POST -/p/!new PersonNewR GET -/p/#ShrIdent PersonR GET +/p PeopleR GET POST +/p/!new PersonNewR GET +/p/#ShrIdent PersonR GET -/g GroupsR GET POST -/g/!new GroupNewR GET -/g/#ShrIdent GroupR GET -/g/#ShrIdent/m GroupMembersR GET POST -/g/#ShrIdent/m/!new GroupMemberNewR GET -/g/#ShrIdent/m/#ShrIdent GroupMemberR GET DELETE POST +/g GroupsR GET POST +/g/!new GroupNewR GET +/g/#ShrIdent GroupR GET +/g/#ShrIdent/m GroupMembersR GET POST +/g/#ShrIdent/m/!new GroupMemberNewR GET +/g/#ShrIdent/m/#ShrIdent GroupMemberR GET DELETE POST -/k KeysR GET POST -/k/!new KeyNewR GET -/k/#KyIdent KeyR GET DELETE POST +/k KeysR GET POST +/k/!new KeyNewR GET +/k/#KyIdent KeyR GET DELETE POST -/cr ClaimRequestsR GET +/cr ClaimRequestsPersonR GET -/s/#ShrIdent/rr RepoRolesR GET POST -/s/#ShrIdent/rr/!new RepoRoleNewR GET -/s/#ShrIdent/rr/#RlIdent RepoRoleR GET DELETE POST -/s/#ShrIdent/rr/#RlIdent/a RepoRoleOpsR GET POST -/s/#ShrIdent/rr/#RlIdent/a/!new RepoRoleOpNewR GET +/s/#ShrIdent/rr RepoRolesR GET POST +/s/#ShrIdent/rr/!new RepoRoleNewR GET +/s/#ShrIdent/rr/#RlIdent RepoRoleR GET DELETE POST +/s/#ShrIdent/rr/#RlIdent/a RepoRoleOpsR GET POST +/s/#ShrIdent/rr/#RlIdent/a/!new RepoRoleOpNewR GET -/s/#ShrIdent/pr ProjectRolesR GET POST -/s/#ShrIdent/pr/!new ProjectRoleNewR GET -/s/#ShrIdent/pr/#RlIdent ProjectRoleR GET DELETE POST -/s/#ShrIdent/pr/#RlIdent/a ProjectRoleOpsR GET POST -/s/#ShrIdent/pr/#RlIdent/a/!new ProjectRoleOpNewR GET +/s/#ShrIdent/pr ProjectRolesR GET POST +/s/#ShrIdent/pr/!new ProjectRoleNewR GET +/s/#ShrIdent/pr/#RlIdent ProjectRoleR GET DELETE POST +/s/#ShrIdent/pr/#RlIdent/a ProjectRoleOpsR GET POST +/s/#ShrIdent/pr/#RlIdent/a/!new ProjectRoleOpNewR GET -- ---------------------------------------------------------------------------- -- Projects -- ---------------------------------------------------------------------------- -/s/#ShrIdent/r ReposR GET POST -/s/#ShrIdent/r/!new RepoNewR GET -/s/#ShrIdent/r/#RpIdent RepoR GET PUT DELETE POST -/s/#ShrIdent/r/#RpIdent/edit RepoEditR GET -/s/#ShrIdent/r/#RpIdent/s/+Texts RepoSourceR GET -/s/#ShrIdent/r/#RpIdent/c RepoHeadChangesR GET -/s/#ShrIdent/r/#RpIdent/c/#Text RepoChangesR GET -/s/#ShrIdent/r/#RpIdent/d RepoDevsR GET POST -/s/#ShrIdent/r/#RpIdent/d/!new RepoDevNewR GET -/s/#ShrIdent/r/#RpIdent/d/#ShrIdent RepoDevR GET DELETE POST +/s/#ShrIdent/r ReposR GET POST +/s/#ShrIdent/r/!new RepoNewR GET +/s/#ShrIdent/r/#RpIdent RepoR GET PUT DELETE POST +/s/#ShrIdent/r/#RpIdent/edit RepoEditR GET +/s/#ShrIdent/r/#RpIdent/s/+Texts RepoSourceR GET +/s/#ShrIdent/r/#RpIdent/c RepoHeadChangesR GET +/s/#ShrIdent/r/#RpIdent/c/#Text RepoChangesR GET +/s/#ShrIdent/r/#RpIdent/d RepoDevsR GET POST +/s/#ShrIdent/r/#RpIdent/d/!new RepoDevNewR GET +/s/#ShrIdent/r/#RpIdent/d/#ShrIdent RepoDevR GET DELETE POST -/s/#ShrIdent/r/#RpIdent/_darcs/+Texts DarcsDownloadR GET +/s/#ShrIdent/r/#RpIdent/_darcs/+Texts DarcsDownloadR GET -/s/#ShrIdent/r/#RpIdent/git/info/refs GitRefDiscoverR GET +/s/#ShrIdent/r/#RpIdent/git/info/refs GitRefDiscoverR GET --/s/#ShrIdent/r/#RpIdent/git/git-upload-pack GitUploadRequestR POST -/s/#ShrIdent/p ProjectsR GET POST -/s/#ShrIdent/p/!new ProjectNewR GET -/s/#ShrIdent/p/#PrjIdent ProjectR GET PUT POST -/s/#ShrIdent/p/#PrjIdent/edit ProjectEditR GET -/s/#ShrIdent/p/#PrjIdent/d ProjectDevsR GET POST -/s/#ShrIdent/p/#PrjIdent/d/!new ProjectDevNewR GET -/s/#ShrIdent/p/#PrjIdent/d/#ShrIdent ProjectDevR GET DELETE POST +/s/#ShrIdent/p ProjectsR GET POST +/s/#ShrIdent/p/!new ProjectNewR GET +/s/#ShrIdent/p/#PrjIdent ProjectR GET PUT POST +/s/#ShrIdent/p/#PrjIdent/edit ProjectEditR GET +/s/#ShrIdent/p/#PrjIdent/d ProjectDevsR GET POST +/s/#ShrIdent/p/#PrjIdent/d/!new ProjectDevNewR GET +/s/#ShrIdent/p/#PrjIdent/d/#ShrIdent ProjectDevR GET DELETE POST -/s/#ShrIdent/p/#PrjIdent/t TicketsR GET POST -/s/#ShrIdent/p/#PrjIdent/t/!new TicketNewR GET -/s/#ShrIdent/p/#PrjIdent/t/#Int TicketR GET PUT DELETE POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/edit TicketEditR GET -/s/#ShrIdent/p/#PrjIdent/t/#Int/close TicketCloseR POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/open TicketOpenR POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/claim TicketClaimR POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/unclaim TicketUnclaimR POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/assign TicketAssignR GET POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/unassign TicketUnassignR POST -/s/#ShrIdent/p/#PrjIdent/tcr TicketClaimRequestsR GET -/s/#ShrIdent/p/#PrjIdent/t/#Int/d TicketDiscussionR GET POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/d/#Int TicketMessageR GET POST -/s/#ShrIdent/p/#PrjIdent/t/#Int/d/!reply TicketTopReplyR GET -/s/#ShrIdent/p/#PrjIdent/t/#Int/d/#Int/reply TicketReplyR GET +/s/#ShrIdent/p/#PrjIdent/t TicketsR GET POST +/s/#ShrIdent/p/#PrjIdent/t/!new TicketNewR GET +/s/#ShrIdent/p/#PrjIdent/t/#Int TicketR GET PUT DELETE POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/edit TicketEditR GET +/s/#ShrIdent/p/#PrjIdent/t/#Int/close TicketCloseR POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/open TicketOpenR POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/claim TicketClaimR POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/unclaim TicketUnclaimR POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/assign TicketAssignR GET POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/unassign TicketUnassignR POST +/s/#ShrIdent/p/#PrjIdent/tcr ClaimRequestsProjectR GET +/s/#ShrIdent/p/#PrjIdent/t/#Int/cr ClaimRequestsTicketR GET +/s/#ShrIdent/p/#PrjIdent/t/#Int/d TicketDiscussionR GET POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/d/#Int TicketMessageR GET POST +/s/#ShrIdent/p/#PrjIdent/t/#Int/d/!reply TicketTopReplyR GET +/s/#ShrIdent/p/#PrjIdent/t/#Int/d/#Int/reply TicketReplyR GET -/s/#ShrIdent/p/#PrjIdent/w/+Texts WikiPageR GET +/s/#ShrIdent/p/#PrjIdent/w/+Texts WikiPageR GET diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index eea1329..95839cc 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -130,7 +130,7 @@ instance Yesod App where (KeyR _key , _ ) -> personAny (KeyNewR , _ ) -> personAny - (ClaimRequestsR , _ ) -> personAny + (ClaimRequestsPersonR , _ ) -> personAny (RepoRolesR shr , _ ) -> personOrGroupAdmin shr (RepoRoleNewR shr , _ ) -> personOrGroupAdmin shr @@ -368,7 +368,7 @@ instance YesodBreadcrumbs App where KeyNewR -> ("New", Just KeysR) KeyR key -> (ky2text key, Just KeysR) - ClaimRequestsR -> ( "Ticket Claim Requests" + ClaimRequestsPersonR -> ( "Ticket Claim Requests" , Just HomeR ) @@ -454,9 +454,12 @@ instance YesodBreadcrumbs App where , Just $ TicketR shr prj num ) TicketUnassignR _shr _prj _num -> ("", Nothing) - TicketClaimRequestsR shr prj -> ( "Ticket Claim Requests" + ClaimRequestsProjectR shr prj -> ( "Ticket Claim Requests" , Just $ ProjectR shr prj ) + ClaimRequestsTicketR shr prj num -> ( "Ticket Claim Requests" + , Just $ TicketR shr prj num + ) TicketDiscussionR shar proj num -> ( "Discussion" , Just $ TicketR shar proj num ) diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 2cb9834..6c5d07e 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -29,8 +29,9 @@ module Vervis.Handler.Ticket , getTicketAssignR , postTicketAssignR , postTicketUnassignR - , getClaimRequestsR - , getTicketClaimRequestsR + , getClaimRequestsPersonR + , getClaimRequestsProjectR + , getClaimRequestsTicketR , getTicketDiscussionR , postTicketDiscussionR , getTicketMessageR @@ -389,8 +390,8 @@ postTicketUnassignR shr prj num = do -- | The logged-in user gets a list of the ticket claim requests they have -- opened, in any project. -getClaimRequestsR :: Handler Html -getClaimRequestsR = do +getClaimRequestsPersonR :: Handler Html +getClaimRequestsPersonR = do pid <- requireAuthId rqs <- runDB $ select $ from $ \ (tcr `InnerJoin` ticket `InnerJoin` project `InnerJoin` sharer) -> do @@ -409,8 +410,8 @@ getClaimRequestsR = do defaultLayout $(widgetFile "person/claim-requests") -- | Get a list of ticket claim requests for a given project. -getTicketClaimRequestsR :: ShrIdent -> PrjIdent -> Handler Html -getTicketClaimRequestsR shr prj = do +getClaimRequestsProjectR :: ShrIdent -> PrjIdent -> Handler Html +getClaimRequestsProjectR shr prj = do rqs <- runDB $ do Entity sid _ <- getBy404 $ UniqueSharer shr Entity jid _ <- getBy404 $ UniqueProject prj sid @@ -431,6 +432,21 @@ getTicketClaimRequestsR shr prj = do , ticket ^. TicketTitle , tcr ^. TicketClaimRequestCreated ) + defaultLayout $(widgetFile "project/claim-request/list") + +-- | Get a list of ticket claim requests for a given ticket. +getClaimRequestsTicketR :: ShrIdent -> PrjIdent -> Int -> Handler Html +getClaimRequestsTicketR shr prj num = do + rqs <- runDB $ do + Entity sid _ <- getBy404 $ UniqueSharer shr + Entity jid _ <- getBy404 $ UniqueProject prj sid + Entity tid _ <- getBy404 $ UniqueTicket jid num + select $ from $ \ (tcr `InnerJoin` person `InnerJoin` sharer) -> do + on $ person ^. PersonIdent E.==. sharer ^. SharerId + on $ tcr ^. TicketClaimRequestPerson E.==. person ^. PersonId + where_ $ tcr ^. TicketClaimRequestTicket E.==. val tid + orderBy [desc $ tcr ^. TicketClaimRequestCreated] + return (sharer, tcr) defaultLayout $(widgetFile "ticket/claim-request/list") selectDiscussionId :: ShrIdent -> PrjIdent -> Int -> AppDB DiscussionId diff --git a/templates/personal-overview.hamlet b/templates/personal-overview.hamlet index d9a7e32..df40c48 100644 --- a/templates/personal-overview.hamlet +++ b/templates/personal-overview.hamlet @@ -44,4 +44,4 @@ $# .

Ticket claim requests

- Ticket claim requests + Ticket claim requests diff --git a/templates/project/claim-request/list.hamlet b/templates/project/claim-request/list.hamlet new file mode 100644 index 0000000..0cf2a00 --- /dev/null +++ b/templates/project/claim-request/list.hamlet @@ -0,0 +1,30 @@ +$# This file is part of Vervis. +$# +$# Written in 2016 by fr33domlover . +$# +$# ♡ 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 +$# . + + + + +
Opened on + Opened by + # + Title + $forall (Entity _ sharer, Value num, Value title, Value time) <- rqs +
+ #{showDate time} + + ^{personLinkW sharer} + + #{num} + + #{title} diff --git a/templates/project/one.hamlet b/templates/project/one.hamlet index ea2ea68..511001c 100644 --- a/templates/project/one.hamlet +++ b/templates/project/one.hamlet @@ -27,7 +27,7 @@ $# .
  • Tickets
  • - Ticket claim requests + Ticket claim requests

    Collaborators diff --git a/templates/ticket/claim-request/list.hamlet b/templates/ticket/claim-request/list.hamlet index 0cf2a00..4807371 100644 --- a/templates/ticket/claim-request/list.hamlet +++ b/templates/ticket/claim-request/list.hamlet @@ -16,15 +16,12 @@ $# .

  • Opened on Opened by - # - Title - $forall (Entity _ sharer, Value num, Value title, Value time) <- rqs + Message + $forall (Entity _ sharer, Entity _ tcr) <- rqs
    - #{showDate time} + #{showDate $ ticketClaimRequestCreated tcr} ^{personLinkW sharer} - #{num} - - #{title} + ^{renderSourceT Markdown $ ticketClaimRequestMessage tcr} diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index 80bbb7b..4a3f377 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -47,6 +47,9 @@ $if not $ ticketDone ticket Assign to someone else . +

    + Claim requests +

    Status: # $if ticketDone ticket