Skip to content

Commit

Permalink
Merge pull request #1646 from hennevogel/bugfix_374
Browse files Browse the repository at this point in the history
Bugfix 374
  • Loading branch information
mdeniz committed Mar 22, 2016
2 parents af7a276 + 91e8cf5 commit 8358411
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,12 @@ def delete_dialog
def remove
authorize @package, :destroy?

if @package.check_weak_dependencies? && @package.destroy
# Don't check weak dependencies if we force
unless params[:force]
@package.check_weak_dependencies?
end
if @package.errors.empty?
@package.destroy
redirect_to(project_show_path(@project), notice: "Package was successfully removed.")
else
redirect_to(package_show_path(project: @project, package: @package),
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def changerequest
end
end
end
end

accept_request if changestate == 'accepted'
accept_request if changestate == 'accepted'
end

redirect_to :action => 'show', :id => params[:id]
end
Expand Down
24 changes: 22 additions & 2 deletions src/api/app/views/webui/package/_delete_dialog.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
<div class="dialog" id="disable_mask"></div>
<div class="dialog darkgrey_box" id="del_dialog">
<div class="box box-shadow">
<h2 class="box-header">Delete Confirmation</h2>
<h2 class="box-header">Do you really want to delete this package?</h2>
<div class="dialog-content">
<p>Do you really want to delete <%= package_link @package %>?</p>
<%- if @package.develpackages.any? %>
<p>
<%= sprite_tag 'dialog-warning' %>
Warning: This package is used by the following packages for development
</p>
<ul>
<%- @package.develpackages.each do|package| %>
<li><%= project_or_package_link project: package.project.name, package: package.name, short: true %></li>
<%- end %>
</ul>
<% else %>
<p> Please confirm deletion of <%= package_link @package %></p>
<% end %>
</div>
<%= form_tag({:controller => :package, :action => :remove}, :method => :post) do %>
<%= hidden_field_tag(:project, @project) %>
<%= hidden_field_tag(:package, @package) %>
<%- if @package.develpackages.any? %>
<p>
<label for="force">
Delete anyway?
</label>
<input id="force" name="force" type="checkbox" />
</p>
<% end %>
<div class="dialog-buttons">
<%= submit_tag('Ok') %>
<%= remove_dialog_tag('Cancel') %>
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def flash_message_type
def delete_package project, package
visit package_show_path(package: package, project: project)
find(:id, 'delete-package').click
find(:id, 'del_dialog').must_have_text 'Delete Confirmation'
find(:id, 'del_dialog').must_have_text 'Do you really want to delete this package?'
find_button('Ok').click
find('#flash-messages').must_have_text "Package was successfully removed."
end
Expand Down

0 comments on commit 8358411

Please sign in to comment.