Minor fixes

This commit is contained in:
Michael Snoyman 2012-01-07 19:23:56 +02:00
parent 8ba59eac43
commit ad12ce63f0
2 changed files with 5 additions and 4 deletions

View File

@ -43,7 +43,7 @@ library
, persistent >= 0.7 && < 0.8 , persistent >= 0.7 && < 0.8
, persistent-template >= 0.7 && < 0.8 , persistent-template >= 0.7 && < 0.8
, SHA >= 1.4.1.3 && < 1.6 , SHA >= 1.4.1.3 && < 1.6
, http-conduit >= 1.0 && < 1.1 , http-conduit >= 1.1 && < 1.2
, aeson >= 0.5 , aeson >= 0.5
, pwstore-fast >= 2.2 && < 3 , pwstore-fast >= 2.2 && < 3

View File

@ -53,6 +53,7 @@ import Data.Time (Day, TimeOfDay(..))
import qualified Text.Email.Validate as Email import qualified Text.Email.Validate as Email
import Network.URI (parseURI) import Network.URI (parseURI)
import Database.Persist (PersistField) import Database.Persist (PersistField)
import Database.Persist.Query (Entity (..))
import Text.HTML.SanitizeXSS (sanitizeBalance) import Text.HTML.SanitizeXSS (sanitizeBalance)
import Control.Monad (when, unless) import Control.Monad (when, unless)
import Data.List (intersect, nub) import Data.List (intersect, nub)
@ -414,12 +415,12 @@ optionsPersist :: ( YesodPersist master, PersistEntity a
, PersistQuery (YesodPersistBackend master) (GHandler sub master) , PersistQuery (YesodPersistBackend master) (GHandler sub master)
, PathPiece (Key (YesodPersistBackend master) a) , PathPiece (Key (YesodPersistBackend master) a)
) )
=> [Filter a] -> [SelectOpt a] -> (a -> Text) -> GHandler sub master (OptionList (Key (YesodPersistBackend master) a, a)) => [Filter a] -> [SelectOpt a] -> (a -> Text) -> GHandler sub master (OptionList (Entity (YesodPersistBackend master) a))
optionsPersist filts ords toDisplay = fmap mkOptionList $ do optionsPersist filts ords toDisplay = fmap mkOptionList $ do
pairs <- runDB $ selectList filts ords pairs <- runDB $ selectList filts ords
return $ map (\(key, value) -> Option return $ map (\(Entity key value) -> Option
{ optionDisplay = toDisplay value { optionDisplay = toDisplay value
, optionInternalValue = (key, value) , optionInternalValue = Entity key value
, optionExternalValue = toPathPiece key , optionExternalValue = toPathPiece key
}) pairs }) pairs