Module: Katello::Authorization::Product::ClassMethods

Defined in:
app/models/katello/authorization/product.rb

Instance Method Summary collapse

Instance Method Details

#deletableObject



34
35
36
# File 'app/models/katello/authorization/product.rb', line 34

def deletable
  authorized(:destroy_products)
end

#editableObject



30
31
32
# File 'app/models/katello/authorization/product.rb', line 30

def editable
  authorized(:edit_products)
end

#readableObject



26
27
28
# File 'app/models/katello/authorization/product.rb', line 26

def readable
  authorized(:view_products)
end

#readable?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/katello/authorization/product.rb', line 42

def readable?
  ::User.current.can?(:view_products)
end

#readable_repositories(repo_ids = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/katello/authorization/product.rb', line 46

def readable_repositories(repo_ids = nil)
  query = Katello::Repository.all

  if repo_ids
    query = query.where(:id => repo_ids)
  end

  query.joins(:product)
       .joins(:content_view_version)
       .where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.default.pluck(:id))
       .where(:product_id => Katello::Product.readable.pluck(:id))
end

#syncableObject



38
39
40
# File 'app/models/katello/authorization/product.rb', line 38

def syncable
  authorized(:sync_products)
end

#syncable?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/katello/authorization/product.rb', line 59

def syncable?
  ::User.current.can?(:sync_products)
end