Commit 43c975ee authored by Christopher League's avatar Christopher League
Browse files

Link to binary numbers notes, use log mesg

parent 2a534b70
......@@ -57,6 +57,7 @@ import qualified Data.Map as Map
import Data.String (fromString)
import Data.Typeable
import Network.Mail.Mime as Mail
import qualified Data.Text as Text
import Text.Pandoc hiding (getCurrentTime)
import Text.Shakespeare.Text (stext)
import UnliftIO.IORef (IORef, modifyIORef, readIORef)
......@@ -486,16 +487,17 @@ requireAuth :: AppHandler m => m UserEntity
requireAuth =
requireAuthId >>= cachedAuth
updateAuth :: AppHandler m => (User -> User) -> m UserEntity
updateAuth change = do
updateAuth :: AppHandler m => Text -> (User -> User) -> m UserEntity
updateAuth why change = do
uid <- requireAuthId
new <- runRw (updatePureY uid change)
let mesg = Text.unwords [userIdText uid, why]
new <- runRw (logMessage mesg >> updatePureY uid change)
cacheSet (CachedAuth (uid, new))
return (uid, new)
updateAuth_ :: AppHandler m => (User -> User) -> m ()
updateAuth_ change =
updateAuth change $> ()
updateAuth_ :: AppHandler m => Text -> (User -> User) -> m ()
updateAuth_ why change =
updateAuth why change $> ()
isAuthenticated :: AppHandler m => m Bool
isAuthenticated =
......
......@@ -131,6 +131,10 @@ unit1 = do
Convert to base
^{pointsBadgeU1ToBase}
^{dueBadge u1ToBaseDeadline}
<li .list-group-item>
Notes:
<a href=@{PageDocR "notes120-binary.org"}>
Binary numbers
|]
getHomeR :: Handler Html
......
......@@ -226,6 +226,9 @@ sub {
top: 1.1ex;
left: 5px;
}
.base-ten, .foreign-base {
white-space: nowrap;
}
.base-ten > input {
width: 5em;
}
......@@ -383,8 +386,10 @@ handleU1ToBaseR = do
else 2
newPts = min u1ToBaseMaxPoints (origPts + award)
deltaPts = newPts - origPts
when (deltaPts > 0) $
updateAuth_ (userScores . at u1ToBaseKey ?~ newPts)
when (deltaPts > 0) $ do
uid <- requireAuthId
updateAuth_ ("u1ToBase points := " <> show newPts)
(userScores . at u1ToBaseKey ?~ newPts)
deleteSession u1ToBaseKey
addMessage "success" [shamlet|
<b>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment