Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove attach_files

Oliver Güntherf6305c6a82b2
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index a251638085e..d1243713c11 100644
--- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -54,8 +54,6 @@ module Redmine
:attachments_claimed
send :include, Redmine::Acts::Attachable::InstanceMethods
-
- OpenProject::Deprecation.deprecate_method self, :attach_files
end
private
@@ -174,26 +172,6 @@ module Redmine
(persisted? && allowed_to_on_attachment?(user, self.class.attachable_options[:add_on_persisted_permission]))
end
- # Bulk attaches a set of files to an object
- # @deprecated
- # Either use the already existing Attachments::CreateService or
- # write/extend Services for the attached to object.
- # The service should rely on the attachments_replacements variable.
- # See:
- # * app/services/attachments/set_replacements.rb
- # * app/services/attachments/replace_attachments.rb
- def attach_files(attachments)
- return unless attachments&.is_a?(Hash)
-
- attachments.each_value do |attachment|
- if attachment['file']
- build_attachments_from_hash(attachment)
- elsif attachment['id']
- memoize_attachment_for_claiming(attachment)
- end
- end
- end
-
private
def allowed_to_on_attachment?(user, permissions)
@@ -222,21 +200,6 @@ module Redmine
(Redmine::Acts::Attachable.attachables & self.class.ancestors).first
end
- def build_attachments_from_hash(attachment_hash)
- if (file = attachment_hash['file']) && file && file.size.positive?
- attachments.build(file: file,
- container: self,
- description: attachment_hash['description'].to_s.strip,
- author: User.current)
- end
- end
-
- def memoize_attachment_for_claiming(attachment_hash)
- self.attachments_claimed ||= []
- attachment = Attachment.find(attachment_hash['id'])
- self.attachments_claimed << attachment unless id && attachment.container_id == id
- end
-
def validate_attachments_claimable
return unless claimed_attachments?