2016-07-05 03:40:42 -04:00
|
|
|
class ProtectedBranch::PushAccessLevel < ActiveRecord::Base
|
2016-08-16 01:09:13 -04:00
|
|
|
include ProtectedBranchAccess
|
|
|
|
|
2016-07-29 02:13:07 -04:00
|
|
|
validates :access_level, presence: true, inclusion: { in: [Gitlab::Access::MASTER,
|
|
|
|
Gitlab::Access::DEVELOPER,
|
|
|
|
Gitlab::Access::NO_ACCESS] }
|
2016-07-08 02:15:02 -04:00
|
|
|
|
2016-07-13 23:42:16 -04:00
|
|
|
def self.human_access_levels
|
|
|
|
{
|
2016-07-29 02:13:07 -04:00
|
|
|
Gitlab::Access::MASTER => "Masters",
|
|
|
|
Gitlab::Access::DEVELOPER => "Developers + Masters",
|
|
|
|
Gitlab::Access::NO_ACCESS => "No one"
|
2016-07-13 23:42:16 -04:00
|
|
|
}.with_indifferent_access
|
|
|
|
end
|
|
|
|
|
2016-07-08 02:15:02 -04:00
|
|
|
def check_access(user)
|
2016-07-29 02:13:07 -04:00
|
|
|
return false if access_level == Gitlab::Access::NO_ACCESS
|
2016-07-29 03:01:15 -04:00
|
|
|
|
2016-11-29 06:21:50 -05:00
|
|
|
super
|
2016-07-08 02:15:02 -04:00
|
|
|
end
|
2016-07-05 03:40:42 -04:00
|
|
|
end
|