summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-23 10:01:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-23 10:01:16 +0000
commit77626ef6fbf2df028ccf01f6a72e459bfc70e2ab (patch)
tree226c3c315e1f3d3162dfac14535821156c703532 /vendor
parentd086683b17665719aa352074288b90ba954e6db0 (diff)
downloadredmine-77626ef6fbf2df028ccf01f6a72e459bfc70e2ab.tar.gz
redmine-77626ef6fbf2df028ccf01f6a72e459bfc70e2ab.zip
Adds support for adding attachments to issues through the REST API (#8171).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8928 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor')
-rw-r--r--vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index 346e0ab8f..afae0751d 100644
--- a/vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -61,18 +61,23 @@ module Redmine
end
def save_attachments(attachments, author=User.current)
- if attachments && attachments.is_a?(Hash)
- attachments.each_value do |attachment|
+ if attachments.is_a?(Hash)
+ attachments = attachments.values
+ end
+ if attachments.is_a?(Array)
+ attachments.each do |attachment|
a = nil
if file = attachment['file']
- next unless file && file.size > 0
- a = Attachment.create(:file => file,
- :description => attachment['description'].to_s.strip,
- :author => author)
+ next unless file.size > 0
+ a = Attachment.create(:file => file, :author => author)
elsif token = attachment['token']
a = Attachment.find_by_token(token)
+ next unless a
+ a.filename = attachment['filename'] unless attachment['filename'].blank?
+ a.content_type = attachment['content_type']
end
next unless a
+ a.description = attachment['description'].to_s.strip
if a.new_record?
unsaved_attachments << a
else