Module: ForemanExpireHosts::HostsHelper

Defined in:
app/helpers/foreman_expire_hosts/hosts_helper.rb

Instance Method Summary collapse

Instance Method Details

#expire_hosts_host_multiple_actionsObject



5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/foreman_expire_hosts/hosts_helper.rb', line 5

def expire_hosts_host_multiple_actions
  actions = []
  if authorized_for(:controller => :hosts, :action => :select_multiple_expiration)
    actions << {
      action: [_('Change Expiration'), select_multiple_expiration_hosts_path],
      priority: 200
    }
  end
  actions
end

#future_time_in_words(to_time, options = {}) ⇒ Object



31
32
33
# File 'app/helpers/foreman_expire_hosts/hosts_helper.rb', line 31

def future_time_in_words(to_time, options = {})
  distance_of_time_in_words(to_time, Time.current, options)
end

#host_expiry_warning_message(host) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/foreman_expire_hosts/hosts_helper.rb', line 16

def host_expiry_warning_message(host)
  return nil unless host.expires?

  if host.expired_past_grace_period?
    message = _('This host has expired %s ago and needs to be deleted manually.') % time_ago_in_words(host.expired_on)
  elsif host.expired?
    message = _('This host has expired %{time_ago} ago and will be deleted on %{delete_date}.') % { :delete_date => l(host.expiration_grace_period_end_date), :time_ago => time_ago_in_words(host.expired_on) }
  elsif host.expires_today?
    message = _('This host will expire today.')
  elsif host.pending_expiration?
    message = _('This host will expire in %{distance_of_time} (on %{expire_date}).') % { :expire_date => l(host.expired_on), :distance_of_time => future_time_in_words(host.expired_on) }
  end
  message
end