Return role and repository count info in GET project API

This commit is contained in:
Wenkai Yin 2018-03-20 19:09:06 +08:00
parent 340080f9a2
commit a7a72f78bd

View File

@ -199,6 +199,8 @@ func (p *ProjectAPI) Get() {
}
}
p.populateProperties(p.project)
p.Data["json"] = p.project
p.ServeJSON()
}
@ -372,6 +374,15 @@ func (p *ProjectAPI) List() {
}
for _, project := range result.Projects {
p.populateProperties(project)
}
p.SetPaginationHeader(result.Total, page, size)
p.Data["json"] = result.Projects
p.ServeJSON()
}
func (p *ProjectAPI) populateProperties(project *models.Project) {
if p.SecurityCtx.IsAuthenticated() {
roles := p.SecurityCtx.GetProjectRoles(project.ProjectID)
if len(roles) != 0 {
@ -393,11 +404,6 @@ func (p *ProjectAPI) List() {
project.RepoCount = len(repos)
}
p.SetPaginationHeader(result.Total, page, size)
p.Data["json"] = result.Projects
p.ServeJSON()
}
// Put ...
func (p *ProjectAPI) Put() {
if !p.SecurityCtx.IsAuthenticated() {