0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00
discourse-custom-wizard/lib/custom_wizard/extensions/topic_extension.rb

23 Zeilen
575 B
Ruby

# frozen_string_literal: true
module CustomWizardTopicExtension
extend ActiveSupport::Concern
included { before_validation :check_wizard_replacement, on: :create }
def check_wizard_replacement
if wizard_replacing_composer?(self.category_id)
self.errors.add(
:base,
I18n.t('wizard.error_messages.wizard_replacing_composer')
)
end
end
def wizard_replacing_composer?(category_id)
return false unless category_id
category = Category.find(category_id)
category.custom_fields['create_topic_wizard'].present?
end
end