diff --git a/config/models b/config/models index 4035f5f..f48cf19 100644 --- a/config/models +++ b/config/models @@ -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 ------------------------------------------------------------------------------- diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 3217275..c1e443c 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -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 diff --git a/src/Vervis/Ssh.hs b/src/Vervis/Ssh.hs index 0ebd130..c452175 100644 --- a/src/Vervis/Ssh.hs +++ b/src/Vervis/Ssh.hs @@ -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