From e398c86854f56c998cfdf546ab66a7bb4e5ab34a Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Wed, 1 Jun 2016 16:20:19 +0000 Subject: [PATCH] Ticket assignee field --- config/models | 21 ++++++++-------- src/Vervis/Form/Ticket.hs | 1 + src/Vervis/Handler/Ticket.hs | 46 +++++++++++++++++++++--------------- templates/ticket/one.hamlet | 6 +++++ 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/config/models b/config/models index c5b0cc1..5b62fc9 100644 --- a/config/models +++ b/config/models @@ -117,16 +117,17 @@ Repo UniqueRepo ident sharer Ticket - project ProjectId - number Int - created UTCTime - creator PersonId - title Text - desc Text -- Assume this is Pandoc Markdown - done Bool - closed UTCTime - closer PersonId - discuss DiscussionId + project ProjectId + number Int + created UTCTime + creator PersonId + title Text + desc Text -- Assume this is Pandoc Markdown + assignee PersonId Maybe + done Bool + closed UTCTime + closer PersonId + discuss DiscussionId UniqueTicket project number diff --git a/src/Vervis/Form/Ticket.hs b/src/Vervis/Form/Ticket.hs index 57f7858..bd625c1 100644 --- a/src/Vervis/Form/Ticket.hs +++ b/src/Vervis/Form/Ticket.hs @@ -70,6 +70,7 @@ editTicketAForm ticket pid = fmap fixDone $ Ticket "Description (Markdown)" (Just $ Just $ Textarea $ ticketDesc ticket) ) + <*> pure (ticketAssignee ticket) <*> areq checkBoxField "Done*" (Just $ ticketDone ticket) <*> now <*> pure (ticketCloser ticket) diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index a104bbf..570588b 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -40,6 +40,7 @@ import Data.Text (Text) import Data.Time.Calendar (Day (..)) import Data.Time.Clock (UTCTime (..), getCurrentTime) import Data.Time.Format (formatTime, defaultTimeLocale) +import Data.Traversable (for) import Database.Esqueleto hiding ((==.), (+=.), update) import Database.Persist import Text.Blaze.Html (Html, toHtml) @@ -106,16 +107,17 @@ postTicketsR shar proj = do } did <- insert discussion let ticket = Ticket - { ticketProject = pid - , ticketNumber = projectNextTicket project - , ticketCreated = now - , ticketCreator = author - , ticketTitle = ntTitle nt - , ticketDesc = ntDesc nt - , ticketDone = False - , ticketClosed = UTCTime (ModifiedJulianDay 0) 0 - , ticketCloser = author - , ticketDiscuss = did + { ticketProject = pid + , ticketNumber = projectNextTicket project + , ticketCreated = now + , ticketCreator = author + , ticketTitle = ntTitle nt + , ticketDesc = ntDesc nt + , ticketAssignee = Nothing + , ticketDone = False + , ticketClosed = UTCTime (ModifiedJulianDay 0) 0 + , ticketCloser = author + , ticketDiscuss = did } insert_ ticket return $ ticketNumber ticket @@ -135,19 +137,25 @@ getTicketNewR shar proj = do getTicketR :: ShrIdent -> PrjIdent -> Int -> Handler Html getTicketR shar proj num = do - (author, closer, ticket) <- runDB $ do - Entity sid _sharer <- getBy404 $ UniqueSharer shar - Entity pid _project <- getBy404 $ UniqueProject proj sid - Entity _tid ticket <- getBy404 $ UniqueTicket pid num - person <- get404 $ ticketCreator ticket - author <- get404 $ personIdent person + (author, massignee, closer, ticket) <- runDB $ do + ticket <- do + Entity s _ <- getBy404 $ UniqueSharer shar + Entity p _ <- getBy404 $ UniqueProject proj s + Entity _ t <- getBy404 $ UniqueTicket p num + return t + author <- do + person <- get404 $ ticketCreator ticket + get404 $ personIdent person + massignee <- for (ticketAssignee ticket) $ \ pid -> do + person <- get404 pid + get404 $ personIdent person closer <- if ticketDone ticket then do - person' <- get404 $ ticketCloser ticket - get404 $ personIdent person' + person <- get404 $ ticketCloser ticket + get404 $ personIdent person else return author - return (author, closer, ticket) + return (author, massignee, closer, ticket) let desc = renderSourceT Markdown $ T.filter (/= '\r') $ ticketDesc ticket discuss = discussionW diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index b594cd8..47e5646 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -23,6 +23,12 @@ $# . Created on #{formatTime defaultTimeLocale "%F" $ ticketCreated ticket} by ^{personLinkW author} +

+ $maybe assignee <- massignee + Assigned to ^{personLinkW assignee} + $nothing + Not assigned +

Status: $if ticketDone ticket