diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-10 03:57:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 20:57:58 +0100 |
commit | 99b2858e628d92bba252be72def409af77af735b (patch) | |
tree | 56159cf10b271307911e6f01626c0c3efba789ab /routers/web/repo/view.go | |
parent | b6b1e716654fec3b16d245ef65cf42e57e1bb5b6 (diff) | |
download | gitea-99b2858e628d92bba252be72def409af77af735b.tar.gz gitea-99b2858e628d92bba252be72def409af77af735b.zip |
Move unit into models/unit/ (#17576)
* Move unit into models/unit/
* Rename unit.UnitType as unit.Type
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 } |