Ejemplo n.º 1
0
func (this *OrganizationWebV1Controller) GetPrivateRepos() {
	org := new(models.Organization)
	repos := make([]models.Repository, 0)

	if exist, _, err := org.Has(this.Ctx.Input.Param(":org")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Organization not exist", nil)
		return
	}

	for _, v := range org.Repositories {
		repo := new(models.Repository)

		if err := repo.Get(v); err != nil {
			this.JSONOut(http.StatusBadRequest, "Repository invalid", nil)
			return
		}

		if repo.Privated == true {
			repos = append(repos, *repo)
		}
	}

	this.JSONOut(http.StatusOK, "", repos)
	return
}