Browse Source

Merge pull request '任务权限代码优化' (#1045) from fix-969 into V20211213

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1045
Reviewed-by: lewis <747342561@qq.com>
pull/1047/head
lewis 3 years ago
parent
commit
9bcf7a6ac4
3 changed files with 4 additions and 13 deletions
  1. +1
    -10
      modules/cloudbrain/cloudbrain.go
  2. +1
    -1
      routers/repo/cloudbrain.go
  3. +2
    -2
      routers/repo/modelarts.go

+ 1
- 10
modules/cloudbrain/cloudbrain.go View File

@@ -46,16 +46,7 @@ func isAdminOrOwnerOrJobCreater(ctx *context.Context, job *models.Cloudbrain, er

}

func CanDeleteDebugJob(ctx *context.Context, job *models.Cloudbrain) bool {

if job.Status != string(models.JobStopped) && job.Status != string(models.JobFailed) && job.Status != string(models.ModelArtsStartFailed) && job.Status != string(models.ModelArtsCreateFailed) {
return false
}

return isAdminOrOwnerOrJobCreater(ctx, job, nil)
}

func CanDeleteTrainJob(ctx *context.Context, job *models.Cloudbrain) bool {
func CanDeleteJob(ctx *context.Context, job *models.Cloudbrain) bool {

return isAdminOrOwnerOrJobCreater(ctx, job, nil)
}


+ 1
- 1
routers/repo/cloudbrain.go View File

@@ -78,7 +78,7 @@ func CloudBrainIndex(ctx *context.Context) {
ciTasks[i].CanDebug = false
}

ciTasks[i].CanDel = cloudbrain.CanDeleteDebugJob(ctx, &task.Cloudbrain)
ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain)

}



+ 2
- 2
routers/repo/modelarts.go View File

@@ -74,7 +74,7 @@ func NotebookIndex(ctx *context.Context) {
} else {
ciTasks[i].CanDebug = false
}
ciTasks[i].CanDel = cloudbrain.CanDeleteDebugJob(ctx, &task.Cloudbrain)
ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain)
}

pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5)
@@ -306,7 +306,7 @@ func TrainJobIndex(ctx *context.Context) {
}

for i, task := range tasks {
tasks[i].CanDel = cloudbrain.CanDeleteTrainJob(ctx, &task.Cloudbrain)
tasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain)
tasks[i].CanModify = cloudbrain.CanModifyJob(ctx, &task.Cloudbrain)
}



Loading…
Cancel
Save