debian-mirror-gitlab/app/models/members/member_role.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
795 B
Ruby
Raw Normal View History

2022-08-27 11:52:29 +05:30
# frozen_string_literal: true
class MemberRole < ApplicationRecord # rubocop:disable Gitlab/NamespacedClass
2023-03-04 22:38:38 +05:30
include IgnorableColumns
ignore_column :download_code, remove_with: '15.9', remove_after: '2023-01-22'
2022-08-27 11:52:29 +05:30
has_many :members
belongs_to :namespace
2022-11-25 23:54:43 +05:30
validates :namespace, presence: true
2022-08-27 11:52:29 +05:30
validates :base_access_level, presence: true
2022-11-25 23:54:43 +05:30
validate :belongs_to_top_level_namespace
2023-03-04 22:38:38 +05:30
validate :validate_namespace_locked, on: :update
validates_associated :members
2022-11-25 23:54:43 +05:30
private
def belongs_to_top_level_namespace
return if !namespace || namespace.root?
2023-03-04 22:38:38 +05:30
errors.add(:namespace, s_("MemberRole|must be top-level namespace"))
end
def validate_namespace_locked
return unless namespace_id_changed?
errors.add(:namespace, s_("MemberRole|can't be changed"))
2022-11-25 23:54:43 +05:30
end
2022-08-27 11:52:29 +05:30
end