debian-mirror-gitlab/app/models/concerns/protected_branch_access.rb

36 lines
772 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
module ProtectedBranchAccess
extend ActiveSupport::Concern
2017-09-10 17:25:29 +05:30
ALLOWED_ACCESS_LEVELS ||= [
Gitlab::Access::MASTER,
Gitlab::Access::DEVELOPER,
Gitlab::Access::NO_ACCESS
].freeze
2016-11-03 12:29:30 +05:30
included do
2017-08-17 22:00:37 +05:30
include ProtectedRefAccess
belongs_to :protected_branch
2016-11-03 12:29:30 +05:30
2017-08-17 22:00:37 +05:30
delegate :project, to: :protected_branch
2017-09-10 17:25:29 +05:30
validates :access_level, presence: true, inclusion: {
in: ALLOWED_ACCESS_LEVELS
}
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
2016-09-13 17:45:13 +05:30
end
end