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

[#38954] IFC upload not working since attachment whitelisting

Wieland Lindenthal3a4687ff9f6e
diff --git a/modules/bim/app/models/bim/ifc_models/ifc_model.rb b/modules/bim/app/models/bim/ifc_models/ifc_model.rb
index 940acb76fe1..6499e433d06 100644
--- a/modules/bim/app/models/bim/ifc_models/ifc_model.rb
+++ b/modules/bim/app/models/bim/ifc_models/ifc_model.rb
@@ -13,7 +13,7 @@ module Bim
scope :defaults, -> { where(is_default: true) }
- %i(ifc xkt metadata).each do |name|
+ %i(ifc xkt).each do |name|
define_method "#{name}_attachment" do
get_attached_type(name)
end
@@ -27,7 +27,7 @@ module Bim
delete_attachment name
call = ::Attachments::CreateService
.bypass_whitelist(user: User.current)
- .call(file: file, container: self, filename: file.original_filename, description: name)
+ .call(file: file, container: self, filename: File.basename(file.path), description: name)
call.on_failure { Rails.logger.error "Failed to add #{name} attachment: #{call.message}" }
end
diff --git a/modules/bim/app/services/bim/ifc_models/set_attributes_service.rb b/modules/bim/app/services/bim/ifc_models/set_attributes_service.rb
index b703ceee161..a28c1b2934e 100644
--- a/modules/bim/app/services/bim/ifc_models/set_attributes_service.rb
+++ b/modules/bim/app/services/bim/ifc_models/set_attributes_service.rb
@@ -34,6 +34,7 @@ module Bim
protected
def set_attributes(params)
+ model.project = params[:project]
set_ifc_attachment(params.delete(:ifc_attachment))
super
diff --git a/modules/bim/spec/features/bcf/direct_ifc_upload_spec.rb b/modules/bim/spec/features/ifc_models/direct_ifc_upload_spec.rb
similarity index 100%
rename from modules/bim/spec/features/bcf/direct_ifc_upload_spec.rb
rename to modules/bim/spec/features/ifc_models/direct_ifc_upload_spec.rb