From aa3831ee6bd06abf334bed5332dc9942d1b9ffe9 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Wed, 3 Mar 2021 09:19:34 +0100 Subject: [PATCH] Introduce basic structures for teams --- Handler/ShowChallenge.hs | 3 ++- Model.hs | 1 + PersistTeamActionType.hs | 20 ++++++++++++++++++++ config/models | 15 +++++++++++++++ gonito.cabal | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 PersistTeamActionType.hs diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 8dd686e..02599c9 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -896,7 +896,8 @@ getSubmission userId repoId commit challengeId subDescription chan = do submissionSubmitter=userId, submissionIsPublic=False, submissionIsHidden=False, - submissionVersion=challengeVersion challenge} + submissionVersion=challengeVersion challenge, + submissionTeam=Nothing } getSubmissionRepo :: UserId -> Key Challenge -> RepoSpec -> Channel -> Handler (Maybe (Key Repo)) getSubmissionRepo userId challengeId repoSpec chan = getPossiblyExistingRepo checkRepoAvailibility userId challengeId repoSpec chan diff --git a/Model.hs b/Model.hs index 6d8e5c9..758d479 100644 --- a/Model.hs +++ b/Model.hs @@ -9,6 +9,7 @@ import GEval.Core import GEval.EvaluationScheme import PersistMetric import PersistEvaluationScheme +import PersistTeamActionType -- You can define all of your database entities in the entities file. -- You can find more information on persistent and how to declare entities diff --git a/PersistTeamActionType.hs b/PersistTeamActionType.hs new file mode 100644 index 0000000..270d17c --- /dev/null +++ b/PersistTeamActionType.hs @@ -0,0 +1,20 @@ +module PersistTeamActionType where + +import ClassyPrelude.Yesod +import Database.Persist.Sql + +import qualified Data.Text as T + +data TeamActionType = TeamCreation | TeamJoining | TeamLeaving + deriving (Eq, Show, Read) + +instance PersistField TeamActionType where + toPersistValue m = PersistText (T.pack $ show m) + + fromPersistValue (PersistText t) = case readMay t of + Just val -> Right val + Nothing -> Left ("Unexpected value '" ++ t ++ "'") + fromPersistValue _ = Left "Unexpected value" + +instance PersistFieldSql TeamActionType where + sqlType _ = SqlString diff --git a/config/models b/config/models index 9573f44..c9b2e86 100644 --- a/config/models +++ b/config/models @@ -12,6 +12,20 @@ User triggerToken Text Maybe altRepoScheme Text Maybe deriving Typeable +Team + ident Text + avatar ByteString Maybe + UniqueTeam ident +TeamMember + user UserId + team TeamId + isCaptain Bool +TeamLog + stamp UTCTime default=now() + actionType TeamActionType + agens UserId + patiens UserId Maybe + verificationKey Text Maybe PublicKey user UserId pubkey Text @@ -90,6 +104,7 @@ Submission isHidden Bool default=False -- challenge version present when the submission was done version SHA1 + team UserId Maybe UniqueSubmissionRepoCommitChallenge repo commit challenge Variant submission SubmissionId diff --git a/gonito.cabal b/gonito.cabal index 60dec32..5c143b9 100644 --- a/gonito.cabal +++ b/gonito.cabal @@ -27,6 +27,7 @@ library PersistEvaluationScheme PersistMetric PersistSHA1 + PersistTeamActionType Settings Settings.StaticFiles Handler.Common