Merge pull request #1007 from opf/feature/add_attachments_to_api_planning_elements_controller

Feature/add attachments to api planning elements controller
pull/1015/head
Martin Linkhorst 11 years ago
commit fa33c6fe5f
  1. 2
      app/controllers/api/v2/planning_elements_controller.rb
  2. 49
      app/models/permitted_params.rb
  3. 1
      doc/CHANGELOG.md

@ -61,6 +61,8 @@ module Api
@planning_element = @project.work_packages.build
@planning_element.update_attributes(permitted_params.planning_element.except :note)
@planning_element.attach_files(params[:attachments])
# The planning_element inherits from workpackage, which requires an author.
# Using the current_user also satisfies this demand for API-calls
@planning_element.author ||= current_user

@ -326,23 +326,25 @@ class PermittedParams < Struct.new(:params, :user)
:member => [
:role_ids => []],
:new_work_package => [
:subject,
# attributes common with :planning_element below
:assigned_to_id,
{ attachments: [:file, :description] },
:category_id,
:description,
:start_date,
:done_ratio,
:due_date,
:parent_id,
:assigned_to_id,
:responsible_id,
:type_id,
:fixed_version_id,
:estimated_hours,
:done_ratio,
:fixed_version_id,
:parent_id,
:priority_id,
:category_id,
:responsible_id,
:start_date,
:status_id,
:type_id,
:subject,
# attributes unique to :new_work_package
:notes,
:lock_version,
{ attachments: [:file, :description] },
Proc.new do |args|
# avoid costly allowed_to? if the param is not there at all
if args[:params]["work_package"].has_key?("watcher_user_ids") &&
@ -360,22 +362,25 @@ class PermittedParams < Struct.new(:params, :user)
end
end ],
:planning_element => [
:subject,
# attributes common with :new_work_package above
:assigned_to_id,
{ attachments: [:file, :description] },
:category_id,
:description,
:start_date,
:done_ratio,
:due_date,
:note,
:type_id,
:status_id,
:planning_element_status_comment,
:parent_id,
:responsible_id,
:assigned_to_id,
:fixed_version_id,
:estimated_hours,
:done_ratio,
:fixed_version_id,
:parent_id,
:priority_id,
:category_id,
:responsible_id,
:start_date,
:status_id,
:type_id,
:subject,
# attributes unique to planning_element
:note,
:planning_element_status_comment,
:custom_fields => [ #json
:id,
:value,

@ -31,6 +31,7 @@ See doc/COPYRIGHT.rdoc for more details.
* `#5057` Fix: Whitelisted more params for planning elements controller
* Allowed sending of mails with only cc: or bcc: fields
* Allow adding attachments to created work packages via planning elements controller
## 3.0.0pre51

Loading…
Cancel
Save