本文整理匯總了Golang中github.com/drone/drone/pkg/database.ListTeams函數的典型用法代碼示例。如果您正苦於以下問題:Golang ListTeams函數的具體用法?Golang ListTeams怎麽用?Golang ListTeams使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ListTeams函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RepoSettingsForm
// Repository Settings
func RepoSettingsForm(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) error {
// get the list of teams
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
data := struct {
Repo *Repo
User *User
Teams []*Team
Owner *User
Team *Team
}{Repo: repo, User: u, Teams: teams}
// get the repo owner
if repo.TeamID > 0 {
data.Team, err = database.GetTeam(repo.TeamID)
if err != nil {
return err
}
}
// get the team owner
data.Owner, err = database.GetUser(repo.UserID)
if err != nil {
return err
}
return RenderTemplate(w, "repo_settings.html", &data)
}
示例2: TeamShow
// Display a specific Team.
func TeamShow(w http.ResponseWriter, r *http.Request, u *User) error {
teamParam := r.FormValue(":team")
team, err := database.GetTeamSlug(teamParam)
if err != nil {
return err
}
if member, _ := database.IsMember(u.ID, team.ID); !member {
return fmt.Errorf("Forbidden")
}
// list of repositories owned by Team
repos, err := database.ListReposTeam(team.ID)
if err != nil {
return err
}
// list all user teams
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
// list of recent commits
commits, err := database.ListCommitsTeam(team.ID)
if err != nil {
return err
}
data := struct {
User *User
Team *Team
Teams []*Team
Repos []*Repo
Commits []*RepoCommit
}{u, team, teams, repos, commits}
return RenderTemplate(w, "team_dashboard.html", &data)
}
示例3: UserShow
// Display the dashboard for a specific user
func UserShow(w http.ResponseWriter, r *http.Request, u *User) error {
// list of repositories owned by User
repos, err := database.ListRepos(u.ID)
if err != nil {
return err
}
// list of user team accounts
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
// list of recent commits
commits, err := database.ListCommitsUser(u.ID)
if err != nil {
return err
}
data := struct {
User *User
Repos []*Repo
Teams []*Team
Commits []*RepoCommit
}{u, repos, teams, commits}
return RenderTemplate(w, "user_dashboard.html", &data)
}
示例4: UserTeams
// Display a list of all Teams for the currently authenticated User.
func UserTeams(w http.ResponseWriter, r *http.Request, u *User) error {
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
data := struct {
User *User
Teams []*Team
}{u, teams}
return RenderTemplate(w, "user_teams.html", &data)
}
示例5: RepoAddGithubLimited
func RepoAddGithubLimited(w http.ResponseWriter, r *http.Request, u *User) error {
settings := database.SettingsMust()
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
data := struct {
User *User
Teams []*Team
Settings *Settings
}{u, teams, settings}
// display the template for adding
// a new GitHub repository with read only access.
return RenderTemplate(w, "github_limited_add.html", &data)
}
示例6: RepoAdd
func RepoAdd(w http.ResponseWriter, r *http.Request, u *User) error {
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
data := struct {
User *User
Teams []*Team
}{u, teams}
// if the user hasn't linked their GitHub account
// render a different template
if len(u.GithubToken) == 0 {
return RenderTemplate(w, "github_link.html", &data)
}
// otherwise display the template for adding
// a new GitHub repository.
return RenderTemplate(w, "github_add.html", &data)
}
示例7: Add
func (g *GitlabHandler) Add(w http.ResponseWriter, r *http.Request, u *User) error {
settings := database.SettingsMust()
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
data := struct {
User *User
Teams []*Team
Settings *Settings
}{u, teams, settings}
// if the user hasn't linked their GitLab account
// render a different template
if len(u.GitlabToken) == 0 {
return RenderTemplate(w, "gitlab_link.html", &data)
}
// otherwise display the template for adding
// a new GitLab repository.
return RenderTemplate(w, "gitlab_add.html", &data)
}
示例8: RepoAddBitbucket
func RepoAddBitbucket(w http.ResponseWriter, r *http.Request, u *User) error {
settings := database.SettingsMust()
teams, err := database.ListTeams(u.ID)
if err != nil {
return err
}
data := struct {
User *User
Teams []*Team
Settings *Settings
}{u, teams, settings}
// if the user hasn't linked their Bitbucket account
// render a different template
if len(u.BitbucketToken) == 0 {
return RenderTemplate(w, "bitbucket_link.html", &data)
}
// otherwise display the template for adding
// a new Bitbucket repository.
return RenderTemplate(w, "bitbucket_add.html", &data)
}
示例9: TestListTeam
// Test the ability to get a list of Teams
// to which a User belongs.
func TestListTeam(t *testing.T) {
Setup()
defer Teardown()
teams, err := database.ListTeams(1)
if err != nil {
t.Error(err)
}
// verify team count
if len(teams) != 3 {
t.Errorf("Exepected %d teams in database, got %d", 3, len(teams))
return
}
// get the first user in the list and verify
// fields are being populated correctly
team := teams[0]
if team.ID != 1 {
t.Errorf("Exepected ID %d, got %d", 1, team.ID)
}
if team.Name != "Drone" {
t.Errorf("Exepected Name %s, got %s", "Drone", team.Name)
}
if team.Slug != "drone" {
t.Errorf("Exepected Slug %s, got %s", "drone", team.Slug)
}
if team.Email != "[email protected]" {
t.Errorf("Exepected Email %s, got %s", "[email protected]", team.Email)
}
if team.Gravatar != "8c58a0be77ee441bb8f8595b7f1b4e87" {
t.Errorf("Exepected Gravatar %s, got %s", "8c58a0be77ee441bb8f8595b7f1b4e87", team.Gravatar)
}
}