Route for accepting a New ticket

This commit is contained in:
fr33domlover 2016-08-11 07:58:51 +00:00
parent 3329b49b2e
commit 21192fef26
5 changed files with 30 additions and 3 deletions

View file

@ -114,6 +114,7 @@
/s/#ShrIdent/p/#PrjIdent/t/!new TicketNewR GET /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 TicketR GET PUT DELETE POST
/s/#ShrIdent/p/#PrjIdent/t/#Int/edit TicketEditR GET /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/close TicketCloseR POST
/s/#ShrIdent/p/#PrjIdent/t/#Int/open TicketOpenR 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/claim TicketClaimR POST

View file

@ -182,8 +182,9 @@ instance Yesod App where
(TicketNewR _ _ , _ ) -> personAny (TicketNewR _ _ , _ ) -> personAny
(TicketR user _ _ , True) -> person user (TicketR user _ _ , True) -> person user
(TicketEditR user _ _ , _ ) -> person user (TicketEditR user _ _ , _ ) -> person user
(TicketCloseR user _ _ , _ ) -> person user (TicketAcceptR s j _ , _ ) -> projOp ProjOpAcceptTicket s j
(TicketOpenR user _ _ , _ ) -> person user (TicketCloseR s j _ , _ ) -> projOp ProjOpCloseTicket s j
(TicketOpenR s j _ , _ ) -> projOp ProjOpReopenTicket s j
(TicketClaimR s j _ , _ ) -> projOp ProjOpClaimTicket s j (TicketClaimR s j _ , _ ) -> projOp ProjOpClaimTicket s j
(TicketUnclaimR s j _ , _ ) -> projOp ProjOpUnclaimTicket s j (TicketUnclaimR s j _ , _ ) -> projOp ProjOpUnclaimTicket s j
(TicketAssignR s j _ , _ ) -> projOp ProjOpAssignTicket s j (TicketAssignR s j _ , _ ) -> projOp ProjOpAssignTicket s j
@ -518,6 +519,7 @@ instance YesodBreadcrumbs App where
TicketEditR shar proj num -> ( "Edit" TicketEditR shar proj num -> ( "Edit"
, Just $ TicketR shar proj num , Just $ TicketR shar proj num
) )
TicketAcceptR _shr _prj _num -> ("", Nothing)
TicketCloseR _shar _proj _num -> ("", Nothing) TicketCloseR _shar _proj _num -> ("", Nothing)
TicketOpenR _shar _proj _num -> ("", Nothing) TicketOpenR _shar _proj _num -> ("", Nothing)
TicketClaimR _shar _proj _num -> ("", Nothing) TicketClaimR _shar _proj _num -> ("", Nothing)

View file

@ -23,6 +23,7 @@ module Vervis.Handler.Ticket
, deleteTicketR , deleteTicketR
, postTicketR , postTicketR
, getTicketEditR , getTicketEditR
, postTicketAcceptR
, postTicketCloseR , postTicketCloseR
, postTicketOpenR , postTicketOpenR
, postTicketClaimR , postTicketClaimR
@ -323,6 +324,24 @@ getTicketEditR shar proj num = do
runFormPost $ editTicketContentForm tid ticket wid runFormPost $ editTicketContentForm tid ticket wid
defaultLayout $(widgetFile "ticket/edit") 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 :: ShrIdent -> PrjIdent -> Int -> Handler Html
postTicketCloseR shr prj num = do postTicketCloseR shr prj num = do
pid <- requireAuthId pid <- requireAuthId

View file

@ -28,7 +28,10 @@ data RepoOperation = RepoOpPush deriving (Eq, Show, Read, Enum, Bounded)
derivePersistField "RepoOperation" derivePersistField "RepoOperation"
data ProjectOperation data ProjectOperation
= ProjOpRequestTicket = ProjOpAcceptTicket
| ProjOpCloseTicket
| ProjOpReopenTicket
| ProjOpRequestTicket
| ProjOpClaimTicket | ProjOpClaimTicket
| ProjOpUnclaimTicket | ProjOpUnclaimTicket
| ProjOpAssignTicket | ProjOpAssignTicket

View file

@ -88,6 +88,8 @@ $if ticketStatus ticket /= TSClosed
$of TSNew $of TSNew
Open, new. 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}> <form method=POST action=@{TicketCloseR shar proj num}>
<input type=submit value="Close this ticket"> <input type=submit value="Close this ticket">
$of TSTodo $of TSTodo