diff --git a/config/routes b/config/routes index 2694682..09baab8 100644 --- a/config/routes +++ b/config/routes @@ -55,7 +55,7 @@ /u/#Text/p/#Text/t TicketsR GET POST /u/#Text/p/#Text/t/!new TicketNewR GET -/u/#Text/p/#Text/t/#Int TicketR GET PUT DELETE +/u/#Text/p/#Text/t/#Int TicketR GET PUT DELETE POST /u/#Text/p/#Text/t/#Int/edit TicketEditR GET -- /u/#Text/p/#Text/w WikiR GET diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index ff99cc6..6853def 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -20,6 +20,7 @@ module Vervis.Handler.Ticket , getTicketR , putTicketR , deleteTicketR + , postTicketR , getTicketEditR ) where @@ -34,7 +35,7 @@ import Database.Persist import Text.Blaze.Html (Html, toHtml) import Yesod.Auth (requireAuthId) import Yesod.Core (defaultLayout) -import Yesod.Core.Handler (setMessage, redirect) +import Yesod.Core.Handler (setMessage, redirect, lookupPostParam, notFound) import Yesod.Core.Widget (setTitle) import Yesod.Form.Functions (runFormPost) import Yesod.Form.Types (FormResult (..)) @@ -146,6 +147,14 @@ deleteTicketR shar proj num = --delete tickets? error "Not implemented" +postTicketR :: Text -> Text -> Int -> Handler Html +postTicketR shar proj num = do + mmethod <- lookupPostParam "_method" + case mmethod of + Just "PUT" -> putTicketR shar proj num + Just "DELETE" -> deleteTicketR shar proj num + _ -> notFound + getTicketEditR :: Text -> Text -> Int -> Handler Html getTicketEditR shar proj num = do Entity _tid ticket <- runDB $ do diff --git a/templates/ticket/edit.hamlet b/templates/ticket/edit.hamlet index e1e33eb..0f5a8dc 100644 --- a/templates/ticket/edit.hamlet +++ b/templates/ticket/edit.hamlet @@ -16,6 +16,7 @@ $# . Enter the details and click "Submit" to update the ticket. -
+ + ^{widget} diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index 22e4bf8..241345d 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -17,7 +17,8 @@ $# .

Edit this ticket

- + +