add rebuild button for users who have admin access to the repo

This commit is contained in:
Michael Nutt
2014-05-22 23:52:03 -04:00
parent 913332d965
commit fbdb330d5c
7 changed files with 127 additions and 18 deletions

View File

@@ -90,3 +90,18 @@ func ListReposTeam(id int64) ([]*Repo, error) {
err := meddler.QueryAll(db, &repos, repoTeamStmt, id)
return repos, err
}
// Checks whether a user is admin of a repo
// Returns true if user owns repo or is on team that owns repo
// Returns true if the user is an admin member of the team.
func IsRepoAdmin(user *User, repo *Repo) (bool, error) {
if user == nil {
return false, nil
}
if user.ID == repo.UserID {
return true, nil
}
return IsMemberAdmin(user.ID, repo.TeamID)
}