Route for accepting a New ticket
This commit is contained in:
parent
3329b49b2e
commit
21192fef26
5 changed files with 30 additions and 3 deletions
|
@ -114,6 +114,7 @@
|
|||
/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/accept TicketAcceptR POST
|
||||
/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
|
||||
|
|
|
@ -182,8 +182,9 @@ instance Yesod App where
|
|||
(TicketNewR _ _ , _ ) -> personAny
|
||||
(TicketR user _ _ , True) -> person user
|
||||
(TicketEditR user _ _ , _ ) -> person user
|
||||
(TicketCloseR user _ _ , _ ) -> person user
|
||||
(TicketOpenR user _ _ , _ ) -> person user
|
||||
(TicketAcceptR s j _ , _ ) -> projOp ProjOpAcceptTicket s j
|
||||
(TicketCloseR s j _ , _ ) -> projOp ProjOpCloseTicket s j
|
||||
(TicketOpenR s j _ , _ ) -> projOp ProjOpReopenTicket s j
|
||||
(TicketClaimR s j _ , _ ) -> projOp ProjOpClaimTicket s j
|
||||
(TicketUnclaimR s j _ , _ ) -> projOp ProjOpUnclaimTicket s j
|
||||
(TicketAssignR s j _ , _ ) -> projOp ProjOpAssignTicket s j
|
||||
|
@ -518,6 +519,7 @@ instance YesodBreadcrumbs App where
|
|||
TicketEditR shar proj num -> ( "Edit"
|
||||
, Just $ TicketR shar proj num
|
||||
)
|
||||
TicketAcceptR _shr _prj _num -> ("", Nothing)
|
||||
TicketCloseR _shar _proj _num -> ("", Nothing)
|
||||
TicketOpenR _shar _proj _num -> ("", Nothing)
|
||||
TicketClaimR _shar _proj _num -> ("", Nothing)
|
||||
|
|
|
@ -23,6 +23,7 @@ module Vervis.Handler.Ticket
|
|||
, deleteTicketR
|
||||
, postTicketR
|
||||
, getTicketEditR
|
||||
, postTicketAcceptR
|
||||
, postTicketCloseR
|
||||
, postTicketOpenR
|
||||
, postTicketClaimR
|
||||
|
@ -323,6 +324,24 @@ getTicketEditR shar proj num = do
|
|||
runFormPost $ editTicketContentForm tid ticket wid
|
||||
defaultLayout $(widgetFile "ticket/edit")
|
||||
|
||||
postTicketAcceptR :: ShrIdent -> PrjIdent -> Int -> Handler Html
|
||||
postTicketAcceptR shr prj num = do
|
||||
succ <- runDB $ do
|
||||
Entity tid ticket <- do
|
||||
Entity s _ <- getBy404 $ UniqueSharer shr
|
||||
Entity p _ <- getBy404 $ UniqueProject prj s
|
||||
getBy404 $ UniqueTicket p num
|
||||
case ticketStatus ticket of
|
||||
TSNew -> do
|
||||
update tid [TicketStatus =. TSTodo]
|
||||
return True
|
||||
_ -> return False
|
||||
setMessage $
|
||||
if succ
|
||||
then "Ticket accepted."
|
||||
else "Ticket is already accepted."
|
||||
redirect $ TicketR shr prj num
|
||||
|
||||
postTicketCloseR :: ShrIdent -> PrjIdent -> Int -> Handler Html
|
||||
postTicketCloseR shr prj num = do
|
||||
pid <- requireAuthId
|
||||
|
|
|
@ -28,7 +28,10 @@ data RepoOperation = RepoOpPush deriving (Eq, Show, Read, Enum, Bounded)
|
|||
derivePersistField "RepoOperation"
|
||||
|
||||
data ProjectOperation
|
||||
= ProjOpRequestTicket
|
||||
= ProjOpAcceptTicket
|
||||
| ProjOpCloseTicket
|
||||
| ProjOpReopenTicket
|
||||
| ProjOpRequestTicket
|
||||
| ProjOpClaimTicket
|
||||
| ProjOpUnclaimTicket
|
||||
| ProjOpAssignTicket
|
||||
|
|
|
@ -88,6 +88,8 @@ $if ticketStatus ticket /= TSClosed
|
|||
$of TSNew
|
||||
Open, new.
|
||||
|
||||
<form method=POST action=@{TicketAcceptR shar proj num}>
|
||||
<input type=submit value="Accept this ticket">
|
||||
<form method=POST action=@{TicketCloseR shar proj num}>
|
||||
<input type=submit value="Close this ticket">
|
||||
$of TSTodo
|
||||
|
|
Loading…
Reference in a new issue