diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-03 17:05:00 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-03 17:05:00 +0000 |
commit | fe1e3ccd18420752979d817fac4408c780ba1da2 (patch) | |
tree | d7c9bbda24e92c5180c8c8f4adeb03c77c3493d8 /vendor | |
parent | 44955a519c77abe09e9706135a0443761604c780 (diff) | |
download | redmine-fe1e3ccd18420752979d817fac4408c780ba1da2.tar.gz redmine-fe1e3ccd18420752979d817fac4408c780ba1da2.zip |
Refactor: Decouple failed attachments and the flash messages
Attachment#attach_files will no longer need to return a flash message,
instead it will put unsaved attachments into object#unsaved_attachments
where the calling object can access them.
A utility method #render_attachment_warning_if_needed is included for setting
the standard flash warning.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3528 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 8 |
1 files changed, 7 insertions, 1 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 78d42c215..e5acdc499 100644 --- a/vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/vendor/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -32,6 +32,8 @@ module Redmine has_many :attachments, options.merge(:as => :container, :order => "#{Attachment.table_name}.created_on", :dependent => :destroy) + attr_accessor :unsaved_attachments + after_initialize :initialize_unsaved_attachments send :include, Redmine::Acts::Attachable::InstanceMethods end end @@ -48,7 +50,11 @@ module Redmine def attachments_deletable?(user=User.current) user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) end - + + def initialize_unsaved_attachments + @unsaved_attachments ||= [] + end + module ClassMethods end end |