2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-06-04 03:40:48 +00:00
|
|
|
module HasPublishing
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
CanBePublished::StateMachine.aasm.events.each do |event|
|
|
|
|
define_method "has_publishing_#{event.name}" do
|
|
|
|
object = klass.find params[:id]
|
|
|
|
object.can_be_published_aasm.aasm.fire! event.name, current_user
|
|
|
|
|
|
|
|
render json: klass.full(params[:id]), status: :ok
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_publishing_update # rubocop:disable Naming/PredicateName
|
|
|
|
params_for_update = params
|
|
|
|
.permit(:id, :internal_at, :published_at, :archived_at)
|
|
|
|
.to_h
|
2022-01-03 07:21:16 +00:00
|
|
|
.to_h { |k, v| [k.to_sym, v == '--now--' ? Time.zone.now : v] }
|
2019-06-04 03:40:48 +00:00
|
|
|
|
|
|
|
model_update_render(klass, params_for_update)
|
|
|
|
end
|
|
|
|
end
|