Skip to content

Commit

Permalink
Merge pull request #1716 from bgeuken/url_for
Browse files Browse the repository at this point in the history
LGTM 👍
  • Loading branch information
mdeniz committed Apr 15, 2016
2 parents 510b8b9 + 671b4d9 commit f6ac472
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/api/app/controllers/webui/request_controller.rb
Expand Up @@ -226,18 +226,14 @@ def forward_request_to(fwd)
end
end
rescue APIException => e
HoptoadNotifier.notify(e, { failed_job: "Failed to forward BsRequest '#{params[:id]}'" })
flash[:error] = "Unable to forward submit: #{e.message}"
redirect_to(:action => 'show', :project => params[:project], :package => params[:package]) and return
redirect_to(request_show_path(params[:id])) and return
end

# link_to isn't available here, so we have to write some HTML. Uses url_for to not hardcode URLs.
flash[:notice] += " and forwarded to
<a href='#{url_for(:controller => 'package',
:action => 'show',
:project => tgt_prj,
:package => tgt_pkg)}'>#{tgt_prj} / #{tgt_pkg}</a>
(request <a href='#{url_for(:action => 'show',
:number => req.number)}'>#{req.number}</a>)"
target_link = ActionController::Base.helpers.link_to("#{tgt_prj} / #{tgt_pkg}", package_show_url(project: tgt_prj, package: tgt_pkg))
request_link = ActionController::Base.helpers.link_to(req.number, request_show_path(req.number))
flash[:notice] += " and forwarded to #{target_link} (request #{request_link})"
end

def diff
Expand Down Expand Up @@ -287,9 +283,10 @@ def delete_request

req.save!
end
flash[:success] = "Created <a href='#{url_for(:controller => 'request',
:action => 'show',
:number => req.number)}'>repository delete request #{req.number}</a>"

request_link = ActionController::Base.helpers.link_to("repository delete request #{req.number}", request_show_path(req.number))
flash[:success] = "Created #{request_link}"

rescue APIException => e
flash[:error] = e.message
redirect_to :controller => :package, :action => :show, :package => params[:package], :project => params[:project] and return if params[:package]
Expand Down

0 comments on commit f6ac472

Please sign in to comment.