Module: Katello::Authorization::Repository::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#deletableObject



54
55
56
# File 'app/models/katello/authorization/repository.rb', line 54

def deletable
  in_product(Katello::Product.authorized(:destroy_products))
end

#editableObject



62
63
64
# File 'app/models/katello/authorization/repository.rb', line 62

def editable
  in_product(Katello::Product.editable)
end

#exportableObject



50
51
52
# File 'app/models/katello/authorization/repository.rb', line 50

def exportable
  in_product(Katello::Product.exportable)
end

#readableObject



24
25
26
27
28
29
30
# File 'app/models/katello/authorization/repository.rb', line 24

def readable
  in_products = Repository.in_product(Katello::Product.authorized(:view_products)).select(:id)
  in_environments = Repository.where(:environment_id => Katello::KTEnvironment.authorized(:view_lifecycle_environments)).select(:id)
  in_content_views = Repository.joins(:content_view_repositories).where("#{ContentViewRepository.table_name}.content_view_id" => Katello::ContentView.readable).select(:id)
  in_versions = Repository.joins(:content_view_version).where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.readable).select(:id)
  joins(:root).where("#{Repository.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?)", in_products, in_content_views, in_versions, in_environments)
end

#readable_as(user) ⇒ Object



32
33
34
35
36
37
38
# File 'app/models/katello/authorization/repository.rb', line 32

def readable_as(user)
  in_products = Repository.in_product(Katello::Product.authorized_as(user, :view_products)).select(:id)
  in_environments = Repository.where(:environment_id => Katello::KTEnvironment.authorized_as(user, :view_lifecycle_environments)).select(:id)
  in_content_views = Repository.joins(:content_view_repositories).where("#{ContentViewRepository.table_name}.content_view_id" => Katello::ContentView.readable_as(user)).select(:id)
  in_versions = Repository.joins(:content_view_version).where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.readable_as(user)).select(:id)
  joins(:root).where("#{Repository.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?)", in_products, in_content_views, in_versions, in_environments)
end

#readable_docker_catalogObject



40
41
42
# File 'app/models/katello/authorization/repository.rb', line 40

def readable_docker_catalog
  readable_docker_catalog_as(User.current)
end

#readable_docker_catalog_as(user) ⇒ Object



44
45
46
47
48
# File 'app/models/katello/authorization/repository.rb', line 44

def readable_docker_catalog_as(user)
  table_name = Repository.table_name
  in_unauth_environments = Repository.joins(:environment).where("#{Katello::KTEnvironment.table_name}.registry_unauthenticated_pull" => true).select(:id)
  Repository.readable_as(user).or(Repository.joins(:root).where("#{table_name}.id in (?)", in_unauth_environments)).non_archived.docker_type
end

#syncableObject



58
59
60
# File 'app/models/katello/authorization/repository.rb', line 58

def syncable
  in_product(Katello::Product.authorized(:sync_products))
end