Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1^2
zouap 4 years ago
parent
commit
ce3d878e8f
2 changed files with 13 additions and 1 deletions
  1. +1
    -0
      models/ai_model_manage.go
  2. +12
    -1
      routers/repo/ai_model_manage.go

+ 1
- 0
models/ai_model_manage.go View File

@@ -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 {


+ 12
- 1
routers/repo/ai_model_manage.go View File

@@ -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


Loading…
Cancel
Save