|
|
@@ -0,0 +1,63 @@ |
|
|
|
package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"net/http" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/convert" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
api "code.gitea.io/gitea/modules/structs" |
|
|
|
"code.gitea.io/gitea/routers/api/v1/utils" |
|
|
|
) |
|
|
|
|
|
|
|
//标注任务可分配人员 |
|
|
|
func ListTagger(ctx *context.APIContext) { |
|
|
|
|
|
|
|
taggers := make([]*api.Tagger, 0) |
|
|
|
userRemember := make(map[string]string) |
|
|
|
collaborators, err := ctx.Repo.Repository.GetCollaborators(utils.GetListOptions(ctx)) |
|
|
|
if err != nil { |
|
|
|
log.Warn("ListCollaborators", err) |
|
|
|
ctx.JSON(http.StatusOK, taggers) |
|
|
|
return |
|
|
|
} |
|
|
|
for _, collaborator := range collaborators { |
|
|
|
taggers = append(taggers, convert.ToTagger(collaborator.User)) |
|
|
|
userRemember[collaborator.User.Name] = "" |
|
|
|
} |
|
|
|
|
|
|
|
teams, err := ctx.Repo.Repository.GetRepoTeams() |
|
|
|
if err != nil { |
|
|
|
log.Warn("ListTeams", err) |
|
|
|
ctx.JSON(http.StatusOK, taggers) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
for _, team := range teams { |
|
|
|
for _, user := range team.Members { |
|
|
|
if _, ok := userRemember[user.Name]; !ok { |
|
|
|
taggers = append(taggers, convert.ToTagger(user)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.JSON(http.StatusOK, taggers) |
|
|
|
|
|
|
|
} |
|
|
|
func GetRight(ctx *context.APIContext) { |
|
|
|
right := "none" |
|
|
|
|
|
|
|
if ctx.IsUserRepoReaderSpecific(models.UnitTypeCode) { |
|
|
|
right = "read" |
|
|
|
} |
|
|
|
|
|
|
|
if ctx.IsUserRepoWriter([]models.UnitType{models.UnitTypeCode}) || ctx.IsUserRepoAdmin() { |
|
|
|
right = "write" |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]string{ |
|
|
|
"right": right, |
|
|
|
}) |
|
|
|
|
|
|
|
} |