From 77496af54ad6db310d42a9b785a25c57ecfeb552 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 2 Oct 2024 18:35:37 +0200 Subject: [PATCH] (bug) unable to sync projects with openprojects --- CHANGELOG.md | 3 +++ app/models/concerns/openlab_sync.rb | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b064d1c9a..6622496a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Next release - Fix a bug: unable to reset OpenApi token +- Fix a bug: unable to sync projects with openprojects +- [TODO DEPLOY] `rails fablab:openlab:bulk_export` +- [TODO DEPLOY] `rails fablab:openlab:bulk_update` ## v6.3.32 2024 July 22 diff --git a/app/models/concerns/openlab_sync.rb b/app/models/concerns/openlab_sync.rb index 38e0315c0..49daddf42 100644 --- a/app/models/concerns/openlab_sync.rb +++ b/app/models/concerns/openlab_sync.rb @@ -5,18 +5,17 @@ module OpenlabSync extend ActiveSupport::Concern included do - after_create :openlab_create, if: :openlab_sync_active? - after_update :openlab_update, if: :openlab_sync_active? + after_save :openlab_create_or_update, if: :openlab_sync_active? after_destroy :openlab_destroy, if: :openlab_sync_active? def openlab_create OpenlabWorker.perform_in(2.seconds, :create, id) if published? end - def openlab_update + def openlab_create_or_update return unless published? - if state_was == 'draft' + if state_was == 'draft' || state_was.nil? OpenlabWorker.perform_async(:create, id) else OpenlabWorker.perform_async(:update, id)