BigW Consortium Gitlab

protected_ref_access.rb 429 Bytes
Newer Older
1 2
module ProtectedRefAccess
  extend ActiveSupport::Concern
3

4 5 6 7
  included do
    scope :master, -> { where(access_level: Gitlab::Access::MASTER) }
    scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) }
  end
8

9 10 11
  def humanize
    self.class.human_access_levels[self.access_level]
  end
12

13
  def check_access(user)
14
    return true if user.admin?
15

16 17 18
    project.team.max_member_access(user.id) >= access_level
  end
end