2016-08-16 01:09:13 -04:00
|
|
|
module ProtectedBranchAccess
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2016-09-06 01:05:34 -04:00
|
|
|
included do
|
2017-04-03 21:59:37 -04:00
|
|
|
include ProtectedRefAccess
|
|
|
|
|
2016-11-29 06:21:50 -05:00
|
|
|
belongs_to :protected_branch
|
2017-04-05 13:59:46 -04:00
|
|
|
|
2016-11-29 06:21:50 -05:00
|
|
|
delegate :project, to: :protected_branch
|
2017-05-10 04:46:50 -04:00
|
|
|
|
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
|
|
|
|
]
|
|
|
|
}
|
2017-05-10 04:46:50 -04:00
|
|
|
|
|
|
|
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-11-29 06:21:50 -05:00
|
|
|
end
|
2016-08-16 01:09:13 -04:00
|
|
|
end
|