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

Fix IFC controller using attachment prepare service

Oliver Günther6972dac08949
diff --git a/app/services/base_services/base_contracted.rb b/app/services/base_services/base_contracted.rb
index a2d688a2ced..91af3410976 100644
--- a/app/services/base_services/base_contracted.rb
+++ b/app/services/base_services/base_contracted.rb
@@ -29,7 +29,7 @@
#++
module BaseServices
- class BaseContracted < BaseCallable
+class BaseContracted < BaseCallable
include Contracted
include Shared::ServiceContext
diff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
index 554081ac570..e72bd748905 100644
--- a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
@@ -176,14 +176,20 @@ module Bim
private
def prepare_form(ifc_model)
- if OpenProject::Configuration.direct_uploads?
- @pending_upload = Attachment.create_pending_direct_upload(file_name: "model.ifc", author: current_user)
- @form = DirectFogUploader.direct_fog_hash(
- attachment: @pending_upload,
- success_action_redirect: direct_upload_finished_bcf_project_ifc_models_url
- )
- session[:pending_ifc_model_ifc_model_id] = ifc_model.id unless ifc_model.new_record?
- end
+ return unless OpenProject::Configuration.direct_uploads?
+
+ call = ::Attachments::PrepareUploadService
+ .new(user: current_user)
+ .call(filename: "model.ifc", filesize: 0)
+
+ call.on_failure { flash[:error] = call.message }
+
+ @pending_upload = call.result
+ @form = DirectFogUploader.direct_fog_hash(
+ attachment: @pending_upload,
+ success_action_redirect: direct_upload_finished_bcf_project_ifc_models_url
+ )
+ session[:pending_ifc_model_ifc_model_id] = ifc_model.id unless ifc_model.new_record?
end
def frontend_redirect(model_ids)