Project

General

Profile

Download (975 Bytes) Statistics
| Branch: | Tag: | Revision:
fa7070ca Ohad Levy
module CommonParametersHelper
9fd7478e Paul Kelly
# 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
ef4b97d1 Joseph Mitchell Magen
User.current.allowed_to?(operation) and User.current.send(controller).include?(instance_variable_get("@#{controller.singularize}"))
9fd7478e Paul Kelly
end
cdf02336 Ohad Levy
def parameters_title
bfbf7ed8 Lukas Zapletal
_("Parameters that would be associated with hosts in this %s") % (type)
cdf02336 Ohad Levy
end

298756ca Amos Benari
def parameter_value_field value
bf4a13d3 Walden Raines
content_tag :div, :class => "form-group condensed" do
298756ca Amos Benari
text_area_tag("value_#{value[:value]}", value[:value], :rows => (value[:value].to_s.lines.count || 1 rescue 1),
bf4a13d3 Walden Raines
:class => "col-md-5", :disabled => true) +
2de7832d Ohad Levy
content_tag(:span, :class => "help-block") { popover(_("Additional info"), _("<b>Source:</b> %s") % _(value[:source].to_s))}
298756ca Amos Benari
end
end

fa7070ca Ohad Levy
end