2017-10-02 03:07:09 -04:00
|
|
|
{-# LANGUAGE EmptyDataDecls #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
|
|
{-# LANGUAGE GADTs #-}
|
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
{-# LANGUAGE NoImplicitPrelude #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
{-# LANGUAGE TypeFamilies #-}
|
|
|
|
module Model where
|
|
|
|
|
|
|
|
import ClassyPrelude.Yesod
|
|
|
|
import Database.Persist.Quasi
|
2017-10-05 19:38:10 -04:00
|
|
|
import Yesod.Auth.HashDB ( HashDBUser(..) )
|
2017-10-10 00:16:50 -04:00
|
|
|
import Text.Mustache ( (~>) )
|
|
|
|
import qualified Text.Mustache as M
|
2017-10-02 03:07:09 -04:00
|
|
|
|
2017-10-10 21:44:33 -04:00
|
|
|
import Model.Entry.Kind ( EntryKind )
|
2017-10-08 01:51:48 -04:00
|
|
|
|
2017-10-02 03:07:09 -04:00
|
|
|
-- You can define all of your database entities in the entities file.
|
|
|
|
-- You can find more information on persistent and how to declare entities
|
|
|
|
-- at:
|
|
|
|
-- http://www.yesodweb.com/book/persistent/
|
|
|
|
share [mkPersist sqlSettings, mkMigrate "migrateAll"]
|
|
|
|
$(persistFileWith lowerCaseSettings "config/models")
|
2017-10-05 19:38:10 -04:00
|
|
|
|
|
|
|
instance HashDBUser User where
|
|
|
|
userPasswordHash = Just . userPassword
|
|
|
|
setPasswordHash pw u = u { userPassword = pw }
|
2017-10-10 00:16:50 -04:00
|
|
|
|
|
|
|
instance M.ToMustache Profile where
|
|
|
|
toMustache p = M.object
|
|
|
|
[ "username" ~> profileUsername p
|
|
|
|
]
|