{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} module Handler.Admin where import Import import Handler.Utils -- import Data.Time -- import qualified Data.Text as T -- import Data.Function ((&)) -- import Yesod.Form.Bootstrap3 import Web.PathPieces (showToPathPiece, readFromPathPiece) -- import Colonnade hiding (fromMaybe) -- import Yesod.Colonnade -- import qualified Data.UUID.Cryptographic as UUID -- BEGIN - Buttons needed only here data CreateButton = CreateMath | CreateInf -- Dummy for Example deriving (Enum, Eq, Ord, Bounded, Read, Show) instance PathPiece CreateButton where -- for displaying the button only, not really for paths toPathPiece = showToPathPiece fromPathPiece = readFromPathPiece instance Button UniWorX CreateButton where label CreateMath = [whamlet|Mathematik|] label CreateInf = "Informatik" cssClass CreateMath = BCInfo cssClass CreateInf = BCPrimary -- END Button needed here getAdminTestR :: Handler Html -- Demo Page. Referenzimplementierungen sollte hier gezeigt werden! getAdminTestR = do (btnWdgt, btnEnctype) <- generateFormPost (buttonForm :: Form CreateButton) defaultLayout $ do -- setTitle "Uni2work Admin Testpage" $(widgetFile "adminTest") postAdminTestR :: Handler Html postAdminTestR = do ((btnResult,_), _) <- runFormPost $ buttonForm case btnResult of (FormSuccess CreateInf) -> setMessage "Informatik-Knopf gedrückt" (FormSuccess CreateMath) -> addMessage "warning" "Knopf Mathematik erkannt" _other -> return () getAdminTestR getAdminUserR :: CryptoUUIDUser -> Handler Html getAdminUserR uuid = do uid <- decrypt uuid User{..} <- runDB $ get404 uid defaultLayout $ [whamlet|