summaryrefslogtreecommitdiff
path: root/Handler/ReferenceItem.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Handler/ReferenceItem.hs')
-rw-r--r--Handler/ReferenceItem.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Handler/ReferenceItem.hs b/Handler/ReferenceItem.hs
new file mode 100644
index 0000000..738c9f3
--- /dev/null
+++ b/Handler/ReferenceItem.hs
@@ -0,0 +1,25 @@
1module Handler.ReferenceItem where
2
3import Import
4
5getReferenceItemR :: ReferenceId -> Handler TypedContent
6getReferenceItemR referenceId = do
7 entity <- runDB $ Entity referenceId <$> get404 referenceId
8 selectRep $ do
9 provideJson entity
10 provideRep (redirect $ ReferenceListingR :#: referenceId :: Handler Html)
11
12
13putReferenceItemR :: ReferenceId -> Handler Value
14putReferenceItemR referenceId = do
15 Reference{..} <- requireCheckJsonBody
16 returnJson . Entity referenceId =<< runDB
17 (updateGet referenceId [ ReferenceKind =. referenceKind
18 , ReferenceNormKind =. referenceNormKind
19 ])
20
21patchReferenceItemR :: ReferenceId -> Handler Value
22patchReferenceItemR = putReferenceItemR -- Just one field
23
24deleteReferenceItemR :: ReferenceId -> Handler ()
25deleteReferenceItemR = runDB . delete