diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index 8f4fbd113..af96444ac 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -35,6 +35,7 @@ type AiModelManage struct { TrainTaskInfo string `xorm:"text NULL"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` + IsCanOper bool } type AiModelQueryOptions struct { diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index c7a0891a6..b122ed460 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -404,7 +404,7 @@ func ShowModelTemplate(ctx *context.Context) { func isQueryRight(ctx *context.Context) bool { if ctx.Repo.Repository.IsPrivate { - if ctx.User.IsAdmin || ctx.Repo.IsAdmin() || ctx.Repo.IsOwner() { + if ctx.User.IsAdmin || ctx.Repo.IsAdmin() || ctx.Repo.IsOwner() || ctx.Repo.CanAccess(models.UnitTypeCloudBrain) { return true } return false @@ -413,6 +413,13 @@ func isQueryRight(ctx *context.Context) bool { } } +func isOper(ctx *context.Context, modelUserId int64) bool { + if ctx.User.IsAdmin || ctx.Repo.IsAdmin() || ctx.Repo.IsOwner() || ctx.User.ID == modelUserId { + return true + } + return false +} + func ShowModelPageInfo(ctx *context.Context) { log.Info("ShowModelInfo start.") if !isQueryRight(ctx) { @@ -439,6 +446,10 @@ func ShowModelPageInfo(ctx *context.Context) { return } + for _, model := range modelResult { + model.IsCanOper = isOper(ctx, model.UserId) + } + mapInterface := make(map[string]interface{}) mapInterface["data"] = modelResult mapInterface["count"] = count