diff options
Diffstat (limited to 'routers/web/repo/view.go')
-rw-r--r-- | routers/web/repo/view.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 90be631c73..72f12e9bf2 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + unit_model "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/charset" @@ -353,7 +354,7 @@ func renderDirectory(ctx *context.Context, treeLink string) { } // Check permission to add or upload new file. - if ctx.Repo.CanWrite(models.UnitTypeCode) && ctx.Repo.IsViewBranch { + if ctx.Repo.CanWrite(unit_model.TypeCode) && ctx.Repo.IsViewBranch { ctx.Data["CanAddFile"] = !ctx.Repo.Repository.IsArchived ctx.Data["CanUploadFile"] = setting.Repository.Upload.Enabled && !ctx.Repo.Repository.IsArchived } @@ -514,7 +515,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st } } else if !ctx.Repo.IsViewBranch { ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch") - } else if !ctx.Repo.CanWrite(models.UnitTypeCode) { + } else if !ctx.Repo.CanWrite(unit_model.TypeCode) { ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.fork_before_edit") } } @@ -563,7 +564,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st } } else if !ctx.Repo.IsViewBranch { ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch") - } else if !ctx.Repo.CanWrite(models.UnitTypeCode) { + } else if !ctx.Repo.CanWrite(unit_model.TypeCode) { ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access") } } @@ -607,13 +608,13 @@ func checkHomeCodeViewable(ctx *context.Context) { } } - var firstUnit *models.Unit + var firstUnit *unit_model.Unit for _, repoUnit := range ctx.Repo.Units { - if repoUnit.Type == models.UnitTypeCode { + if repoUnit.Type == unit_model.TypeCode { return } - unit, ok := models.Units[repoUnit.Type] + unit, ok := unit_model.Units[repoUnit.Type] if ok && (firstUnit == nil || !firstUnit.IsLessThan(unit)) { firstUnit = &unit } |