Skip to content

Commit

Permalink
Display error message correctly that is returned from model.
Browse files Browse the repository at this point in the history
Display correct flash message when there is an error deleting Catalog Item

https://bugzilla.redhat.com/show_bug.cgi?id=1443120
  • Loading branch information
h-kataria committed Apr 20, 2017
1 parent a965a4f commit 78451fe
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/controllers/catalog_controller.rb
Expand Up @@ -268,9 +268,11 @@ def st_delete
if params[:id]
elements.push(params[:id])
process_sts(elements, 'destroy') unless elements.empty?
add_flash(_("The selected %{record} was deleted") %
{:record => ui_lookup(:table => "service_template")}) if @flash_array.nil?
self.x_node = "root"
if @flash_array.nil?
add_flash(_("The selected %{record} was deleted") %
{:record => ui_lookup(:table => "service_template")})
self.x_node = "root"
end
else # showing 1 element, delete it
elements = find_checked_ids_with_rbac(ServiceTemplate)
if elements.empty?
Expand Down Expand Up @@ -632,7 +634,13 @@ def process_sts(sts, task, _display_name = nil)
add_flash(_("%{model} \"%{name}\": Error during '%{task}': %{error_message}") %
{:model => model_name, :name => st_name, :task => task, :error_message => bang.message}, :error)
else
AuditEvent.success(audit)
if st.errors
st.errors.each do |field, msg|
add_flash("#{field.to_s.capitalize} #{msg}", :error)
end
else
AuditEvent.success(audit)
end
end
end
end
Expand Down

0 comments on commit 78451fe

Please sign in to comment.