Introduce basic structures for teams

This commit is contained in:
Filip Gralinski 2021-03-03 09:19:34 +01:00
parent c176c65393
commit aa3831ee6b
5 changed files with 39 additions and 1 deletions

View File

@ -896,7 +896,8 @@ getSubmission userId repoId commit challengeId subDescription chan = do
submissionSubmitter=userId, submissionSubmitter=userId,
submissionIsPublic=False, submissionIsPublic=False,
submissionIsHidden=False, submissionIsHidden=False,
submissionVersion=challengeVersion challenge} submissionVersion=challengeVersion challenge,
submissionTeam=Nothing }
getSubmissionRepo :: UserId -> Key Challenge -> RepoSpec -> Channel -> Handler (Maybe (Key Repo)) getSubmissionRepo :: UserId -> Key Challenge -> RepoSpec -> Channel -> Handler (Maybe (Key Repo))
getSubmissionRepo userId challengeId repoSpec chan = getPossiblyExistingRepo checkRepoAvailibility userId challengeId repoSpec chan getSubmissionRepo userId challengeId repoSpec chan = getPossiblyExistingRepo checkRepoAvailibility userId challengeId repoSpec chan

View File

@ -9,6 +9,7 @@ import GEval.Core
import GEval.EvaluationScheme import GEval.EvaluationScheme
import PersistMetric import PersistMetric
import PersistEvaluationScheme import PersistEvaluationScheme
import PersistTeamActionType
-- You can define all of your database entities in the entities file. -- You can define all of your database entities in the entities file.
-- You can find more information on persistent and how to declare entities -- You can find more information on persistent and how to declare entities

20
PersistTeamActionType.hs Normal file
View File

@ -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

View File

@ -12,6 +12,20 @@ User
triggerToken Text Maybe triggerToken Text Maybe
altRepoScheme Text Maybe altRepoScheme Text Maybe
deriving Typeable 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 PublicKey
user UserId user UserId
pubkey Text pubkey Text
@ -90,6 +104,7 @@ Submission
isHidden Bool default=False isHidden Bool default=False
-- challenge version present when the submission was done -- challenge version present when the submission was done
version SHA1 version SHA1
team UserId Maybe
UniqueSubmissionRepoCommitChallenge repo commit challenge UniqueSubmissionRepoCommitChallenge repo commit challenge
Variant Variant
submission SubmissionId submission SubmissionId

View File

@ -27,6 +27,7 @@ library
PersistEvaluationScheme PersistEvaluationScheme
PersistMetric PersistMetric
PersistSHA1 PersistSHA1
PersistTeamActionType
Settings Settings
Settings.StaticFiles Settings.StaticFiles
Handler.Common Handler.Common