mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-26 20:54:21 +01:00
Merge branch 'dev' for release 6.3.41
This commit is contained in:
commit
6cc8f97e12
@ -2,6 +2,12 @@
|
||||
|
||||
## Next release
|
||||
|
||||
## v6.3.41 2025 February 26
|
||||
|
||||
- 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.40 2025 February 24
|
||||
|
||||
- Fix a bug: machine reservation time in my reservations is incorrect
|
||||
|
@ -1,25 +1,29 @@
|
||||
# frozen_string_literal: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
# module definition
|
||||
# Module for synchronizing objects with OpenLab platform
|
||||
module OpenlabSync
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_save :openlab_create_or_update, if: :openlab_sync_active?
|
||||
after_destroy :openlab_destroy, if: :openlab_sync_active?
|
||||
after_save :openlab_sync_after_save, if: :should_sync_with_openlab?
|
||||
after_destroy :openlab_destroy, if: :should_sync_with_openlab?
|
||||
|
||||
def openlab_sync_after_save
|
||||
if saved_change_to_state? && published?
|
||||
# New publication - create in OpenLab
|
||||
openlab_create
|
||||
elsif published?
|
||||
# Update existing publication
|
||||
openlab_update
|
||||
end
|
||||
end
|
||||
|
||||
def openlab_create
|
||||
OpenlabWorker.perform_in(2.seconds, :create, id) if published?
|
||||
end
|
||||
|
||||
def openlab_create_or_update
|
||||
return unless published?
|
||||
|
||||
if state_was == 'draft' || state_was.nil?
|
||||
OpenlabWorker.perform_async(:create, id)
|
||||
else
|
||||
OpenlabWorker.perform_async(:update, id)
|
||||
end
|
||||
|
||||
def openlab_update
|
||||
OpenlabWorker.perform_async(:update, id)
|
||||
end
|
||||
|
||||
def openlab_destroy
|
||||
@ -30,6 +34,11 @@ module OpenlabSync
|
||||
OpenLabService.to_hash(self)
|
||||
end
|
||||
|
||||
# Determines if the object should be synced with OpenLab
|
||||
def should_sync_with_openlab?
|
||||
openlab_sync_active? && published?
|
||||
end
|
||||
|
||||
def openlab_sync_active?
|
||||
self.class.openlab_sync_active?
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fab-manager",
|
||||
"version": "6.3.40",
|
||||
"version": "6.3.41",
|
||||
"description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.",
|
||||
"keywords": [
|
||||
"fablab",
|
||||
|
Loading…
x
Reference in New Issue
Block a user