blob: 44cd0a8aa9e8394ff024a6ebf29c6da71163c88e (
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
|
module Handler.ReferenceItem where
import Import
getReferenceItemR :: ReferenceId -> Handler TypedContent
getReferenceItemR referenceId = do
entity <- runDB $ withType =<< Entity referenceId <$> get404 referenceId
selectRep $ do
provideJson entity
provideRep (redirect $ ReferenceListingR :#: referenceId :: Handler Html)
putReferenceItemR :: ReferenceId -> Handler Value
putReferenceItemR referenceId = do
(Reference{..} `WithType` t) <- requireCheckJsonBody
returnJson <=< runDB $ do
entity <- Entity referenceId <$> updateGet referenceId [ ReferenceKind =. referenceKind
, ReferenceNormKind =. referenceNormKind
]
update (referenceFkType $ entityVal entity) [ KindType =. t ]
withType entity
deleteReferenceItemR :: ReferenceId -> Handler ()
deleteReferenceItemR = runDB . delete
|