Added delete link. #1190
This commit is contained in:
@@ -74,6 +74,16 @@ class DeliverablesController < ApplicationController
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
@deliverable = Deliverable.find_by_id_and_project_id(params[:deliverable_id], @project.id)
|
||||
|
||||
render_404 and return unless @deliverable
|
||||
render_403 and return unless @deliverable.editable_by?(User.current)
|
||||
@deliverable.destroy
|
||||
flash[:notice] = l(:notice_successful_delete)
|
||||
redirect_to :action => 'index', :id => @project.id
|
||||
end
|
||||
|
||||
# Create a query in the session and redirects to the issue list with that query
|
||||
def issues
|
||||
@query = Query.new(:name => "_")
|
||||
|
||||
@@ -96,4 +96,10 @@ class Deliverable < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Returns true if the deliverable can be edited by user, otherwise false
|
||||
def editable_by?(user)
|
||||
(user == user && user.allowed_to?(:manage_budget, project))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -32,6 +32,6 @@
|
||||
:td,
|
||||
content_tag(:p,link_to("Assigned Issues", :action => 'issues', :id => @project.id, :deliverable_id => deliverable.id)) +
|
||||
content_tag(:p,link_to("Edit", :action => 'edit', :id => @project.id, :deliverable_id => deliverable.id)) +
|
||||
content_tag(:p,link_to("Delete", :action => 'destroy', :id => @project.id, :deliverable_id => deliverable.id)),
|
||||
content_tag(:p,link_to("Delete", { :action => 'destroy', :id => @project.id, :deliverable_id => deliverable.id}, :confirm => l(:text_are_you_sure))),
|
||||
:colspan => 4) %>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user