packages feed

snaplet-actionlog 0.2 → 0.2.0.1

raw patch · 4 files changed

+15/−19 lines, 4 filesdep ~snap-extras

Dependency ranges changed: snap-extras

Files

snaplet-actionlog.cabal view
@@ -1,5 +1,5 @@ name:           snaplet-actionlog-version:        0.2+version:        0.2.0.1 synopsis:       Generic action log snaplet for the Snap Framework description:    This snaplet contains support for logging website actions.                 Common actions are creating, updating, and deleting records.@@ -54,7 +54,7 @@     readable                   >= 0.1     && < 0.2,     restful-snap               >= 0.1     && < 0.2,     snap                       >= 0.11.3  && < 0.13,-    snap-extras                >= 0.4     && < 0.6,+    snap-extras                >= 0.4     && < 0.7,     snaplet-persistent         >= 0.2     && < 0.3,     text                       >= 0.11    && < 0.12,     time                       >= 1.1     && < 1.5,
src/Snap/Snaplet/ActionLog/API.hs view
@@ -64,6 +64,9 @@ ------------------------------------------------------------------------------ -- | Performs a logged insert into the database.  Just about everything should -- be inserted using this function instead of @runPersist' . insert@+loggedInsert :: (PersistEntity a, HasActionLog m,+                 PersistEntityBackend a ~ SqlBackend)+             => a -> m (Key a) loggedInsert val = do     let entityName = getName val     recKey <- runPersist $ insert val@@ -74,6 +77,9 @@  ------------------------------------------------------------------------------ -- | Performs a logged replace of a database record.+loggedReplace :: (PersistEntity a, CanDelta a, HasActionLog m,+                  PersistEntityBackend a ~ SqlBackend)+              => Key a -> a -> m () loggedReplace key new = do     old <- runPersist $ get key     maybe (return ()) (\o -> loggedReplace' key o new) old@@ -96,6 +102,9 @@  ------------------------------------------------------------------------------ -- | Performs a logged update of a database record.+loggedUpdate :: (PersistEntity a, CanDelta a, HasActionLog m,+                 PersistEntityBackend a ~ SqlBackend)+             => Key a -> [Update a] -> m () loggedUpdate key updates = do     old <- runPersist $ get key     maybe (return ()) (\o -> loggedUpdate' key o updates) old
src/Snap/Snaplet/ActionLog/InternalTypes.hs view
@@ -10,25 +10,12 @@ module Snap.Snaplet.ActionLog.InternalTypes where  -------------------------------------------------------------------------------import           Blaze.ByteString.Builder import           Control.Monad-import           Data.ByteString          (ByteString)-import           Data.Int import           Data.Readable import           Data.Text                (Text)-import qualified Data.Text                as T-import           Data.Text.Encoding-import           Data.Time-import           Data.Word import           Database.Persist-import           Database.Persist.Quasi import           Database.Persist.Sql-import           Database.Persist.TH-import           Heist.Compiled-import qualified Heist.Interpreted        as I import           Snap.Restful-import           Snap.Restful.TH-import           Snap.Snaplet.Persistent ------------------------------------------------------------------------------  
src/Snap/Snaplet/ActionLog/Resource.hs view
@@ -230,7 +230,7 @@               => Resource               -> [(Text, Promise (Entity LoggedAction) -> Splice n)] actionSplices r =-    ("loggedActionUserName", runtimeToPromise getName) :+    ("loggedActionUserName", runtimeToPromise getUserName) :     ("loggedActionDetails", detailsSplice) :     (pureSplices loggedActionCSplices ++      alCustomCSplices ++@@ -238,7 +238,7 @@                (pureSplices $ textSplices $ itemCSplices r)     )   where-    getName = return . fromText <=< alGetName . loggedActionUserId . entityVal+    getUserName = return . fromText <=< alGetName . loggedActionUserId . entityVal     detailsSplice prom =       manyWithSplices runChildren (pureSplices detailsCSplices)         (lift . getActionDetails . entityKey =<< getPromise prom)@@ -354,14 +354,14 @@                -> Entity LoggedAction                -> [(Text, I.Splice m)] actionISplices r e =-    ("loggedActionUserName", I.textSplice =<< getName) :+    ("loggedActionUserName", I.textSplice =<< getUserName) :     ("loggedActionDetails", detailsISplice) :     (loggedActionISplices (entityVal e) ++      alCustomISplices e ++      itemSplices r (DBId $ mkWord64 $ entityKey e)     )   where-    getName = lift $ alGetName $ loggedActionUserId $ entityVal e+    getUserName = lift $ alGetName $ loggedActionUserId $ entityVal e     detailsISplice = do         ds <- lift $ getActionDetails $ entityKey e         I.mapSplices (I.runChildrenWith . detailsISplices . entityVal) ds