gitlab-org--gitlab-foss/app/models/concerns/protected_branch_access.rb

34 lines
730 B
Ruby
Raw Normal View History

module ProtectedBranchAccess
extend ActiveSupport::Concern
included do
include ProtectedRefAccess
belongs_to :protected_branch
delegate :project, to: :protected_branch
2017-05-12 06:41:39 -04:00
validates :access_level, presence: true, inclusion: {
in: [
Gitlab::Access::MASTER,
Gitlab::Access::DEVELOPER,
Gitlab::Access::NO_ACCESS
]
}
def self.human_access_levels
{
Gitlab::Access::MASTER => "Masters",
Gitlab::Access::DEVELOPER => "Developers + Masters",
Gitlab::Access::NO_ACCESS => "No one"
}.with_indifferent_access
end
def check_access(user)
return false if access_level == Gitlab::Access::NO_ACCESS
super
end
end
end