|
@@ -2,6 +2,7 @@ package cloudbrain |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"errors" |
|
|
"errors" |
|
|
|
|
|
"strconv" |
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
|
|
|
|
@@ -30,10 +31,13 @@ var ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func isAdminOrOwnerOrJobCreater(ctx *context.Context, job *models.Cloudbrain, err error) bool { |
|
|
func isAdminOrOwnerOrJobCreater(ctx *context.Context, job *models.Cloudbrain, err error) bool { |
|
|
|
|
|
|
|
|
|
|
|
log.Info("is repo owner:" + strconv.FormatBool(ctx.IsUserRepoOwner())) |
|
|
|
|
|
log.Info("is user admin:" + strconv.FormatBool(ctx.IsUserSiteAdmin())) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
|
|
|
return ctx.IsUserRepoOwner() || ctx.IsUserSiteAdmin() |
|
|
return ctx.IsUserRepoOwner() || ctx.IsUserSiteAdmin() |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
log.Info("is job creator:" + strconv.FormatBool(ctx.User.ID == job.UserID)) |
|
|
return ctx.IsUserRepoOwner() || ctx.IsUserSiteAdmin() || ctx.User.ID == job.UserID |
|
|
return ctx.IsUserRepoOwner() || ctx.IsUserSiteAdmin() || ctx.User.ID == job.UserID |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -44,11 +48,16 @@ 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) { |
|
|
if job.Status != string(models.JobStopped) && job.Status != string(models.JobFailed) && job.Status != string(models.ModelArtsStartFailed) && job.Status != string(models.ModelArtsCreateFailed) { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
if !ctx.IsSigned { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
return isAdminOrOwnerOrJobCreater(ctx, job, nil) |
|
|
return isAdminOrOwnerOrJobCreater(ctx, job, nil) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func CanDeleteTrainJob(ctx *context.Context, job *models.Cloudbrain) bool { |
|
|
func CanDeleteTrainJob(ctx *context.Context, job *models.Cloudbrain) bool { |
|
|
|
|
|
|
|
|
|
|
|
if !ctx.IsSigned { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
return isAdminOrOwnerOrJobCreater(ctx, job, nil) |
|
|
return isAdminOrOwnerOrJobCreater(ctx, job, nil) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|