diff --git app/controllers/projects_controller.rb app/controllers/projects_controller.rb index ef1b5c4..8323bf6 100644 --- app/controllers/projects_controller.rb +++ app/controllers/projects_controller.rb @@ -21,9 +21,9 @@ class ProjectsController < ApplicationController menu_item :settings, :only => :settings before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ] - before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy] + before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive] before_filter :authorize_global, :only => [:new, :create] - before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] + before_filter :require_admin, :only => [ :copy, :archive, :unarchive ] accept_rss_auth :index accept_api_auth :index, :show, :create, :update, :destroy @@ -232,10 +232,23 @@ class ProjectsController < ApplicationController # Delete @project def destroy @project_to_destroy = @project + if request.referer.include?(admin_projects_path) + @destroy_redirect = admin_projects_path + else + @destroy_redirect = home_path + p = @project + while p.parent + if User.current.allowed_to?(:view_project, p.parent) + @destroy_redirect = project_path(p.parent) + break + end + p = p.parent + end + end if api_request? || params[:confirm] @project_to_destroy.destroy respond_to do |format| - format.html { redirect_to admin_projects_path } + format.html { redirect_to @destroy_redirect } format.api { render_api_ok } end end diff --git app/views/projects/destroy.html.erb app/views/projects/destroy.html.erb index ac392b7..5bf7463 100644 --- app/views/projects/destroy.html.erb +++ app/views/projects/destroy.html.erb @@ -13,7 +13,7 @@ <%= form_tag(project_path(@project_to_destroy), :method => :delete) do %> <%= submit_tag l(:button_delete) %> - <%= link_to l(:button_cancel), :controller => 'admin', :action => 'projects' %> + <%= link_to l(:button_cancel), :back %> <% end %>
diff --git app/views/projects/show.html.erb app/views/projects/show.html.erb index 8452a02..8de59fe 100644 --- app/views/projects/show.html.erb +++ app/views/projects/show.html.erb @@ -9,6 +9,9 @@ <%= link_to l(:button_reopen), reopen_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-unlock' %> <% end %> <% end %> + <% if User.current.allowed_to?(:delete_project, @project) %> + <%= link_to(l(:button_delete), project_path(@project), :method => :delete, :class => 'icon icon-del') %> + <% end %>