Specify default role for repo and project visitors
This commit is contained in:
parent
7542b33c7d
commit
6626e40340
3 changed files with 42 additions and 5 deletions
|
@ -79,6 +79,18 @@ RepoCollab
|
||||||
|
|
||||||
UniqueRepoCollab repo person
|
UniqueRepoCollab repo person
|
||||||
|
|
||||||
|
RepoCollabAnon
|
||||||
|
repo RepoId
|
||||||
|
role RepoRoleId
|
||||||
|
|
||||||
|
UniqueRepoCollabAnon repo
|
||||||
|
|
||||||
|
RepoCollabUser
|
||||||
|
repo RepoId
|
||||||
|
role RepoRoleId
|
||||||
|
|
||||||
|
UniqueRepoCollabUser repo
|
||||||
|
|
||||||
ProjectRole
|
ProjectRole
|
||||||
ident RlIdent
|
ident RlIdent
|
||||||
sharer SharerId
|
sharer SharerId
|
||||||
|
@ -105,6 +117,18 @@ ProjectCollab
|
||||||
|
|
||||||
UniqueProjectCollab project person
|
UniqueProjectCollab project person
|
||||||
|
|
||||||
|
ProjectCollabAnon
|
||||||
|
repo ProjectId
|
||||||
|
role ProjectRoleId
|
||||||
|
|
||||||
|
UniqueProjectCollabAnon repo
|
||||||
|
|
||||||
|
ProjectCollabUser
|
||||||
|
repo ProjectId
|
||||||
|
role ProjectRoleId
|
||||||
|
|
||||||
|
UniqueProjectCollabUser repo
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Projects
|
-- Projects
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -250,9 +250,16 @@ instance Yesod App where
|
||||||
ma <- runDB $ runMaybeT $ do
|
ma <- runDB $ runMaybeT $ do
|
||||||
Entity sid _s <- MaybeT $ getBy $ UniqueSharer shr
|
Entity sid _s <- MaybeT $ getBy $ UniqueSharer shr
|
||||||
Entity jid _j <- MaybeT $ getBy $ UniqueProject prj sid
|
Entity jid _j <- MaybeT $ getBy $ UniqueProject prj sid
|
||||||
Entity _cid c <- MaybeT $ getBy $ UniqueProjectCollab jid pid
|
let asCollab = do
|
||||||
let role = projectCollabRole c
|
Entity _cid c <-
|
||||||
roleHas = getBy $ UniqueProjectAccess role op
|
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
|
ancestorHas = getProjectRoleAncestorWithOpQ op role
|
||||||
MaybeT roleHas <|> MaybeT ancestorHas
|
MaybeT roleHas <|> MaybeT ancestorHas
|
||||||
return $ case ma of
|
return $ case ma of
|
||||||
|
|
|
@ -226,8 +226,14 @@ canPushTo shr' rp' = do
|
||||||
ma <- runChanDB $ runMaybeT $ do
|
ma <- runChanDB $ runMaybeT $ do
|
||||||
Entity sid _sharer <- MaybeT $ getBy $ UniqueSharer shr
|
Entity sid _sharer <- MaybeT $ getBy $ UniqueSharer shr
|
||||||
Entity rid _repo <- MaybeT $ getBy $ UniqueRepo rp sid
|
Entity rid _repo <- MaybeT $ getBy $ UniqueRepo rp sid
|
||||||
Entity _cid collab <- MaybeT $ getBy $ UniqueRepoCollab rid pid
|
let asCollab = do
|
||||||
MaybeT $ getBy $ UniqueRepoAccess (repoCollabRole collab) RepoOpPush
|
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
|
return $ isJust ma
|
||||||
|
|
||||||
runAction :: FilePath -> Bool -> Action -> Channel ActionResult
|
runAction :: FilePath -> Bool -> Action -> Channel ActionResult
|
||||||
|
|
Loading…
Reference in a new issue