From f881af18d3e2d524edef3572b94897d21157185f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 8 Jan 2022 21:16:34 +0800 Subject: [PATCH] Fix new team --- models/unit/unit.go | 8 ++++++++ templates/org/team/new.tmpl | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/models/unit/unit.go b/models/unit/unit.go index b05f34b64cca6..eb71276786d1a 100644 --- a/models/unit/unit.go +++ b/models/unit/unit.go @@ -193,6 +193,14 @@ func (u Unit) IsLessThan(unit Unit) bool { return u.Idx < unit.Idx } +// MaxPerm returns the max perms of this unit +func (u Unit) MaxPerm() perm.AccessMode { + if u.Type == TypeExternalTracker || u.Type == TypeExternalWiki { + return perm.AccessModeRead + } + return perm.AccessModeAdmin +} + // Enumerate all the units var ( UnitCode = Unit{ diff --git a/templates/org/team/new.tmpl b/templates/org/team/new.tmpl index 1cf2dd0236ec1..9877e9a9411cb 100644 --- a/templates/org/team/new.tmpl +++ b/templates/org/team/new.tmpl @@ -89,10 +89,10 @@ {{range $t, $unit := $.Units}} - {{if ge $unit.MaxPerms 2}} + {{if ge $unit.MaxPerm 2}} -
{{- else -}}class="field"{{end}}> +
{{$.i18n.Tr $unit.DescKey}} @@ -120,7 +120,7 @@ {{range $t, $unit := $.Units}} - {{if lt $unit.MaxPerms 2}} + {{if lt $unit.MaxPerm 2}}