diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-14 18:33:42 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-14 18:33:42 +0100 |
commit | 7bc954b779a9bc4e1c5e60f2648101c62ed22e72 (patch) | |
tree | b30851324772c14550c0444b7e79e36256f67900 /Handler/ReferenceItem.hs | |
parent | 53fcf55c02f9335518c28d26429913258fc28f87 (diff) | |
download | bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar.gz bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar.bz2 bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.tar.xz bar-7bc954b779a9bc4e1c5e60f2648101c62ed22e72.zip |
Reference & list
Diffstat (limited to 'Handler/ReferenceItem.hs')
-rw-r--r-- | Handler/ReferenceItem.hs | 25 |
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 @@ | |||
1 | module Handler.ReferenceItem where | ||
2 | |||
3 | import Import | ||
4 | |||
5 | getReferenceItemR :: ReferenceId -> Handler TypedContent | ||
6 | getReferenceItemR referenceId = do | ||
7 | entity <- runDB $ Entity referenceId <$> get404 referenceId | ||
8 | selectRep $ do | ||
9 | provideJson entity | ||
10 | provideRep (redirect $ ReferenceListingR :#: referenceId :: Handler Html) | ||
11 | |||
12 | |||
13 | putReferenceItemR :: ReferenceId -> Handler Value | ||
14 | putReferenceItemR referenceId = do | ||
15 | Reference{..} <- requireCheckJsonBody | ||
16 | returnJson . Entity referenceId =<< runDB | ||
17 | (updateGet referenceId [ ReferenceKind =. referenceKind | ||
18 | , ReferenceNormKind =. referenceNormKind | ||
19 | ]) | ||
20 | |||
21 | patchReferenceItemR :: ReferenceId -> Handler Value | ||
22 | patchReferenceItemR = putReferenceItemR -- Just one field | ||
23 | |||
24 | deleteReferenceItemR :: ReferenceId -> Handler () | ||
25 | deleteReferenceItemR = runDB . delete | ||