Added authorization to creating and deleting relations

pull/1645/head
Marek Takac 10 years ago committed by Hagen Schink
parent 651d524194
commit 68a526844d
  1. 8
      lib/api/v3/relations/relations_api.rb

@ -10,7 +10,7 @@ module API
optional :delay
end
post do
# authorize
authorize(:manage_work_package_relations, context: @work_package.project)
declared_params = declared(params).reject{ |key, value| key.to_sym == :id || value.nil? }
relation = @work_package.new_relation.tap do |r|
@ -31,12 +31,10 @@ module API
namespace ':id' do
delete do
# authorize
authorize(:manage_work_package_relations, context: @work_package.project)
relation = Relation.find(params[:id])
model = ::API::V3::WorkPackages::RelationModel.new(relation)
representer = ::API::V3::WorkPackages::RelationRepresenter.new(model)
relation.delete
representer.to_json
status 204
end
end
end

Loading…
Cancel
Save