From cf55550453a216fac5604d74fa93ca8f14266874 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Sun, 14 Feb 2016 08:59:12 +0100 Subject: [PATCH] handle is_anonymous --- Foundation.hs | 2 +- Handler/ShowChallenge.hs | 2 +- Handler/Tables.hs | 10 +++++++--- config/models | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Foundation.hs b/Foundation.hs index c71b2f8..2631f7f 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -175,7 +175,7 @@ instance YesodAuth App where , userName = Nothing , userIsAdmin = False , userLocalId = Nothing - , userIsAnonymous = Just False + , userIsAnonymous = False } -- You can add other plugins like BrowserID, email or OAuth here diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 926e9b7..f0b3121 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -124,7 +124,7 @@ getSubmission repoId commit challengeId description chan = do submissionDescription=description, submissionStamp=time, submissionSubmitter=userId, - submissionIsPublic=Just False } + submissionIsPublic=False } getOuts :: Channel -> Key Submission -> Handler ([Out]) getOuts chan submissionId = do diff --git a/Handler/Tables.hs b/Handler/Tables.hs index 3c23663..29da906 100644 --- a/Handler/Tables.hs +++ b/Handler/Tables.hs @@ -107,9 +107,13 @@ getEvaluationMap s@(Entity submissionId submission) = do formatSubmitter :: User -> Text -formatSubmitter user = case userName user of - Just name -> name - Nothing -> "[name not given]" +formatSubmitter user = if userIsAnonymous user + then + "[anonymised]" + else + case userName user of + Just name -> name + Nothing -> "[name not given]" submissionScore :: Key Test -> (Entity Submission, Entity User, Map (Key Test) Evaluation) -> String submissionScore k (_, _, m) = fromMaybe "N/A" (presentScore <$> lookup k m) diff --git a/config/models b/config/models index a9190fa..c4de368 100644 --- a/config/models +++ b/config/models @@ -5,7 +5,7 @@ User name Text Maybe isAdmin Bool default=False localId Text Maybe - isAnonymous Bool Maybe + isAnonymous Bool default=False deriving Typeable PublicKey user UserId @@ -47,7 +47,7 @@ Submission description Text stamp UTCTime default=now() submitter UserId - isPublic Bool Maybe + isPublic Bool default=False UniqueSubmissionRepoCommitChallenge repo commit challenge Fork source SubmissionId