Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/organizations/organization_user.rb')
-rw-r--r--app/models/organizations/organization_user.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/organizations/organization_user.rb b/app/models/organizations/organization_user.rb
index 5aa1133b017..9e06870dcc6 100644
--- a/app/models/organizations/organization_user.rb
+++ b/app/models/organizations/organization_user.rb
@@ -4,5 +4,17 @@ module Organizations
class OrganizationUser < ApplicationRecord
belongs_to :organization, inverse_of: :organization_users, optional: false
belongs_to :user, inverse_of: :organization_users, optional: false
+
+ validates :user, uniqueness: { scope: :organization_id }
+ validates :access_level, presence: true
+
+ enum access_level: {
+ # Until we develop more access_levels, we really don't know if the default access_level will be what we think of
+ # as a guest. For now, we'll set to same value as guest, but call it default to denote the current ambivalence.
+ default: Gitlab::Access::GUEST,
+ owner: Gitlab::Access::OWNER
+ }
+
+ scope :owners, -> { where(access_level: Gitlab::Access::OWNER) }
end
end