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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix: Trigger IFC conversion for model updates
Wieland Lindenthalf40f57af9de4
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.rbindex f60a2d1267c..168743612f5 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@@ -106,7 +106,7 @@ module Bimifc_model = Bim::IfcModels::IfcModel.find_by id: session[:pending_ifc_model_ifc_model_id]new_model = false- service_result = ::Bim::IfcModels::UpdateService+ service_result = update_service_class.new(user: current_user, model: ifc_model).call(params.with_indifferent_access)@@ -167,7 +167,7 @@ module Bim.to_h.reverse_merge(project: @project)- service_result = ::Bim::IfcModels::UpdateService+ service_result = update_service_class.new(user: current_user, model: @ifc_model).call(combined_params)@@ -209,6 +209,14 @@ module Bimdef find_ifc_model_object@ifc_model = Bim::IfcModels::IfcModel.find_by(id: params[:id])end++ def update_service_class+ if permitted_model_params[:ifc_attachment].present?+ ::Bim::IfcModels::UpdateWithConversionService+ else+ ::Bim::IfcModels::UpdateWithoutConversionService+ end+ endendendenddiff --git a/modules/bim/app/services/bim/ifc_models/update_service.rb b/modules/bim/app/services/bim/ifc_models/update_with_conversion_service.rbsimilarity index 82%rename from modules/bim/app/services/bim/ifc_models/update_service.rbrename to modules/bim/app/services/bim/ifc_models/update_with_conversion_service.rbindex a3f9258ac67..941f07f2875 100644--- a/modules/bim/app/services/bim/ifc_models/update_service.rb+++ b/modules/bim/app/services/bim/ifc_models/update_with_conversion_service.rb@@ -28,24 +28,16 @@module Bimmodule IfcModels- class UpdateService < ::BaseServices::Update+ class UpdateWithConversionService < ::BaseServices::Updateprotected- def before_perform(params)- super.tap do |_service_result|- @ifc_attachment_replaced = model.ifc_attachment.new_record?- end- end-def after_perform(service_result)if service_result.success?# As the attachments association does not have the autosave option, we need to remove the# attachments ourselvesmodel.attachments.select(&:marked_for_destruction?).each(&:destroy)- if @ifc_attachment_replaced- IfcConversionJob.perform_later(service_result.result)- end+ IfcConversionJob.perform_later(service_result.result)endservice_resultdiff --git a/modules/bim/app/services/bim/ifc_models/update_without_conversion_service.rb b/modules/bim/app/services/bim/ifc_models/update_without_conversion_service.rbnew file mode 100644index 00000000000..f498e5aad3d--- /dev/null+++ b/modules/bim/app/services/bim/ifc_models/update_without_conversion_service.rb@@ -0,0 +1,45 @@+#-- copyright+# OpenProject is a project management system.+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2017 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See docs/COPYRIGHT.rdoc for more details.+#+++module Bim+ module IfcModels+ class UpdateWithoutConversionService < ::BaseServices::Update+ protected++ def after_perform(service_result)+ if service_result.success?+ # As the attachments association does not have the autosave option, we need to remove the+ # attachments ourselves+ model.attachments.select(&:marked_for_destruction?).each(&:destroy)+ end++ service_result+ end+ end+ end+end