Module: ForemanProxmox::HostsHelperExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/helpers/concerns/foreman_proxmox/hosts_helper_extensions.rb

Instance Method Summary collapse

Instance Method Details

#display_proxmox_if_Authorized(name, options = {}, html_options = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'app/helpers/concerns/foreman_proxmox/hosts_helper_extensions.rb', line 20

def display_proxmox_if_Authorized(name, options = {}, html_options = {})
  if is_authorized(options)
    link_to(name, proxmox_url(options), html_options)
  else
    ""
  end
end

#host_title_actions_with_proxmox(*args) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/helpers/concerns/foreman_proxmox/hosts_helper_extensions.rb', line 11

def host_title_actions_with_proxmox(*args)
  title_actions(
    button_group(
      display_proxmox_if_Authorized(_("Create VM"), {:controller => 'foreman_proxmox/proxmox', :action => 'create_vm',:id => @host}, :class => 'btn')
      )
    )
  host_title_actions_without_proxmox(*args)
end

#is_authorized(options) ⇒ Object



32
33
34
# File 'app/helpers/concerns/foreman_proxmox/hosts_helper_extensions.rb', line 32

def is_authorized(options)
  User.current.allowed_to?(options)
end

#proxmox_url(options) ⇒ Object



28
29
30
# File 'app/helpers/concerns/foreman_proxmox/hosts_helper_extensions.rb', line 28

def proxmox_url(options)
  ForemanProxmox::Engine.routes.url_for(options.merge(:only_path => true, :script_name => proxmox_create_path))
end