From e54941e44991cea4739381fee90c2d6a79404b00 Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Mon, 23 Sep 2019 21:40:52 +0200 Subject: [PATCH] Move collaborator access mode text logic to template. --- models/repo_collaboration.go | 14 -------------- models/repo_collaboration_test.go | 11 ----------- templates/repo/settings/collaboration.tmpl | 2 +- 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go index 4a027d97f3188..40ddf6a28cfec 100644 --- a/models/repo_collaboration.go +++ b/models/repo_collaboration.go @@ -16,20 +16,6 @@ type Collaboration struct { Mode AccessMode `xorm:"DEFAULT 2 NOT NULL"` } -// ModeI18nKey returns the collaboration mode I18n Key -func (c *Collaboration) ModeI18nKey() string { - switch c.Mode { - case AccessModeRead: - return "repo.settings.collaboration.read" - case AccessModeWrite: - return "repo.settings.collaboration.write" - case AccessModeAdmin: - return "repo.settings.collaboration.admin" - default: - return "repo.settings.collaboration.undefined" - } -} - // AddCollaborator adds new collaboration to a repository with default access mode. func (repo *Repository) AddCollaborator(u *User) error { collaboration := &Collaboration{ diff --git a/models/repo_collaboration_test.go b/models/repo_collaboration_test.go index f11f3c54c3bb9..0842212460802 100644 --- a/models/repo_collaboration_test.go +++ b/models/repo_collaboration_test.go @@ -10,17 +10,6 @@ import ( "github.com/stretchr/testify/assert" ) -func TestCollaboration_ModeI18nKey(t *testing.T) { - assert.Equal(t, "repo.settings.collaboration.read", - (&Collaboration{Mode: AccessModeRead}).ModeI18nKey()) - assert.Equal(t, "repo.settings.collaboration.write", - (&Collaboration{Mode: AccessModeWrite}).ModeI18nKey()) - assert.Equal(t, "repo.settings.collaboration.admin", - (&Collaboration{Mode: AccessModeAdmin}).ModeI18nKey()) - assert.Equal(t, "repo.settings.collaboration.undefined", - (&Collaboration{Mode: AccessModeNone}).ModeI18nKey()) -} - func TestRepository_AddCollaborator(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) diff --git a/templates/repo/settings/collaboration.tmpl b/templates/repo/settings/collaboration.tmpl index d18d9a1910705..b65fd4e1679cf 100644 --- a/templates/repo/settings/collaboration.tmpl +++ b/templates/repo/settings/collaboration.tmpl @@ -20,7 +20,7 @@