blob: 738c9f3b23abd76f3c67f9e2fe5b739cdcc31e4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
module Handler.ReferenceItem where
import Import
getReferenceItemR :: ReferenceId -> Handler TypedContent
getReferenceItemR referenceId = do
entity <- runDB $ Entity referenceId <$> get404 referenceId
selectRep $ do
provideJson entity
provideRep (redirect $ ReferenceListingR :#: referenceId :: Handler Html)
putReferenceItemR :: ReferenceId -> Handler Value
putReferenceItemR referenceId = do
Reference{..} <- requireCheckJsonBody
returnJson . Entity referenceId =<< runDB
(updateGet referenceId [ ReferenceKind =. referenceKind
, ReferenceNormKind =. referenceNormKind
])
patchReferenceItemR :: ReferenceId -> Handler Value
patchReferenceItemR = putReferenceItemR -- Just one field
deleteReferenceItemR :: ReferenceId -> Handler ()
deleteReferenceItemR = runDB . delete
|