2021-03-11 07:30:15 +01:00
|
|
|
# frozen_string_literal: true
|
2020-04-13 14:17:22 +02:00
|
|
|
class CustomWizard::AdminController < ::Admin::AdminController
|
|
|
|
before_action :ensure_admin
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
def index
|
2022-03-25 12:18:54 +01:00
|
|
|
subcription = CustomWizard::Subscription.new
|
2021-09-24 11:58:42 +02:00
|
|
|
render_json_dump(
|
2022-03-25 12:18:54 +01:00
|
|
|
subscribed: subcription.subscribed?,
|
|
|
|
subscription_type: subcription.type,
|
|
|
|
subscription_attributes: CustomWizard::Subscription.attributes,
|
2023-02-24 14:17:00 +01:00
|
|
|
subscription_client_installed: CustomWizard::Subscription.client_installed?
|
2021-09-24 11:58:42 +02:00
|
|
|
)
|
2020-04-13 14:17:22 +02:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
private
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
def find_wizard
|
|
|
|
params.require(:wizard_id)
|
|
|
|
@wizard = CustomWizard::Wizard.create(params[:wizard_id].underscore)
|
2020-11-03 01:24:20 +01:00
|
|
|
raise Discourse::InvalidParameters.new(:wizard_id) unless @wizard
|
2020-04-13 14:17:22 +02:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-10-20 07:40:23 +02:00
|
|
|
def custom_field_list
|
2021-06-08 13:39:49 +02:00
|
|
|
serialize_data(CustomWizard::CustomField.full_list, CustomWizard::CustomFieldSerializer)
|
2020-10-20 07:40:23 +02:00
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
|
2020-11-09 04:32:36 +01:00
|
|
|
def render_error(message)
|
|
|
|
render json: failed_json.merge(error: message)
|
|
|
|
end
|
2021-03-11 07:30:15 +01:00
|
|
|
end
|