Sha256: 6ede03313c4caf9a046fa30d1f175cf5f6d608983e687f40b59d6fa18106a054

Contents?: true

Size: 953 Bytes

Versions: 5

Compression:

Stored size: 953 Bytes

Contents

module CommonParametersHelper
  # Return true if user is authorized for controller/action OR controller/action@type, otherwise false
  def authorized_via_my_scope(controller, action)
    return true if authorized_for(controller, action)

    operation = "#{action}_my_#{controller.singularize}".to_sym
    User.current.allowed_to?(operation) and User.current.send(controller).include?(eval("@#{controller.singularize}"))
  end

  def parameters_title
    _("Parameters that would be associated with hosts in this %s") % (type)
  end

  def parameter_value_field value
    content_tag :div, :class => "control-group condensed"  do
      text_area_tag("value_#{value[:value]}", value[:value], :rows => (value[:value].to_s.lines.count || 1 rescue 1),
                    :class => "span5", :disabled => true) +
      content_tag(:span, :class => "help-inline") { popover(_("Additional info"), _("<b>Source:</b> %s") % (value[:source]))}
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/app/helpers/common_parameters_helper.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/app/helpers/common_parameters_helper.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/app/helpers/common_parameters_helper.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/app/helpers/common_parameters_helper.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/app/helpers/common_parameters_helper.rb