Specify default role for repo and project visitors

This commit is contained in:
fr33domlover 2016-07-03 07:52:11 +00:00
parent 7542b33c7d
commit 6626e40340
3 changed files with 42 additions and 5 deletions

View file

@ -79,6 +79,18 @@ RepoCollab
UniqueRepoCollab repo person
RepoCollabAnon
repo RepoId
role RepoRoleId
UniqueRepoCollabAnon repo
RepoCollabUser
repo RepoId
role RepoRoleId
UniqueRepoCollabUser repo
ProjectRole
ident RlIdent
sharer SharerId
@ -105,6 +117,18 @@ ProjectCollab
UniqueProjectCollab project person
ProjectCollabAnon
repo ProjectId
role ProjectRoleId
UniqueProjectCollabAnon repo
ProjectCollabUser
repo ProjectId
role ProjectRoleId
UniqueProjectCollabUser repo
-------------------------------------------------------------------------------
-- Projects
-------------------------------------------------------------------------------

View file

@ -250,9 +250,16 @@ instance Yesod App where
ma <- runDB $ runMaybeT $ do
Entity sid _s <- MaybeT $ getBy $ UniqueSharer shr
Entity jid _j <- MaybeT $ getBy $ UniqueProject prj sid
Entity _cid c <- MaybeT $ getBy $ UniqueProjectCollab jid pid
let role = projectCollabRole c
roleHas = getBy $ UniqueProjectAccess role op
let asCollab = do
Entity _cid c <-
MaybeT $ getBy $ UniqueProjectCollab jid pid
return $ projectCollabRole c
asUser = do
Entity _cuid cu <-
MaybeT $ getBy $ UniqueProjectCollabUser jid
return $ projectCollabUserRole cu
role <- asCollab <|> asUser
let roleHas = getBy $ UniqueProjectAccess role op
ancestorHas = getProjectRoleAncestorWithOpQ op role
MaybeT roleHas <|> MaybeT ancestorHas
return $ case ma of

View file

@ -226,8 +226,14 @@ canPushTo shr' rp' = do
ma <- runChanDB $ runMaybeT $ do
Entity sid _sharer <- MaybeT $ getBy $ UniqueSharer shr
Entity rid _repo <- MaybeT $ getBy $ UniqueRepo rp sid
Entity _cid collab <- MaybeT $ getBy $ UniqueRepoCollab rid pid
MaybeT $ getBy $ UniqueRepoAccess (repoCollabRole collab) RepoOpPush
let asCollab = do
Entity _ c <- MaybeT $ getBy $ UniqueRepoCollab rid pid
return $ repoCollabRole c
asUser = do
Entity _ cu <- MaybeT $ getBy $ UniqueRepoCollabUser rid
return $ repoCollabUserRole cu
role <- asCollab <|> asUser
MaybeT $ getBy $ UniqueRepoAccess role RepoOpPush
return $ isJust ma
runAction :: FilePath -> Bool -> Action -> Channel ActionResult