Module: Katello::ProvidersHelper

Includes:
SyncManagementHelper, SyncManagementHelper::RepoMethods
Defined in:
app/helpers/katello/providers_helper.rb

Instance Method Summary collapse

Methods included from SyncManagementHelper::RepoMethods

#arches, #collect_arches, #collect_minor, #collect_repos, #minors, #pprint_collection

Methods included from SyncManagementHelper

#any_syncable?, #error_state?, #id, #parent_set_class, #product_child, #product_id, #repo_id, #repos?, #syncable?

Instance Method Details

#label_from_url(provider, url) ⇒ Object



82
83
84
# File 'app/helpers/katello/providers_helper.rb', line 82

def label_from_url(provider, url)
  Util::Model.labelize(name_from_url(provider, url))
end

#name_from_url(provider, url) ⇒ Object



78
79
80
# File 'app/helpers/katello/providers_helper.rb', line 78

def name_from_url(provider, url)
  url.sub(provider.discovery_url, '').tr('/', ' ').strip
end

#normalize(children, parent_set = [], data = [], item_type = nil) ⇒ Object

make the structure plain setting it’s attributes according to the tree (namely id and class)



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/katello/providers_helper.rb', line 58

def normalize(children, parent_set = [], data = [], item_type = nil)
  children.sort { |a, b| a[:name] <=> b[:name] }.each do |child|
    new_set = parent_set + [child[:id]]

    item = { :id    => id(new_set),
             :class => parent_set_class(parent_set),
             :name  => child[:name],
             :item  => child,
             :type  => item_type || child[:type]
    }
    item[:id] = product_id(child[:id]) if item[:type] == "product"

    data << item

    normalize(child[:children], new_set, data) if child[:children].present?
    normalize(child[:repos], new_set, data, "repository") if child[:repos].present?
  end
  data
end

#product_mapObject



50
51
52
53
54
55
# File 'app/helpers/katello/providers_helper.rb', line 50

def product_map
  @product_map ||= normalize(collect_repos(
                                 @provider.products,
                                 current_organization.library))
  @product_map
end

#redhat_repo_tab(provider, tab_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/katello/providers_helper.rb', line 19

def redhat_repo_tab(provider, tab_id)
  tabs = {}.with_indifferent_access
  redhat_repo_tabs.each { |tab| tabs[tab[:id]] = tab }

  provider.products.each do |product|
    product.displayable_product_contents.each do |prod_content|
      name = prod_content.content.name
      if prod_content.content_type == ::Katello::Repository::CANDLEPIN_OSTREE_TYPE
        key = :ostree
      elsif name.include?(" Beta ")
        key = :beta
      elsif name.include?("(Source RPMs)")
        key = :srpms
      elsif name.include?("(Debug RPMs)")
        key = :debug
      elsif name.include?("(ISOs)") || name.include?("Source ISOs")
        key = :isos
      elsif name.include?("(RPMs)")
        key = :rpms
      elsif name.include?("(Kickstart)")
        key = :kickstarts
      else
        key = :other
      end
      tabs[key][:products][product.id] ||= []
      tabs[key][:products][product.id] << prod_content
    end
  end
  tabs[tab_id]
end

#redhat_repo_tabsObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/katello/providers_helper.rb', line 6

def redhat_repo_tabs
  [
    {:id => :rpms, :name => _('RPMs'), :products => {}},
    {:id => :kickstarts, :name => _('Kickstarts'), :products => {}},
    {:id => :srpms, :name => _('Source RPMs'), :products => {}},
    {:id => :debug, :name => _('Debug RPMs'), :products => {}},
    {:id => :beta, :name => _('Beta'), :products => {}},
    {:id => :isos, :name => _('ISOs'), :products => {}},
    {:id => :ostree, :name => _('OSTree'), :products => {}},
    {:id => :other, :name => _('Other'), :products => {}}
  ]
end