2016-08-26 01:14:56 +08:00
|
|
|
require_dependency 'wizard'
|
2016-09-10 04:51:07 +08:00
|
|
|
require_dependency 'wizard/builder'
|
2016-08-26 01:14:56 +08:00
|
|
|
|
|
|
|
class WizardController < ApplicationController
|
2017-08-31 12:06:56 +08:00
|
|
|
before_action :ensure_wizard_enabled, only: [:index]
|
|
|
|
before_action :ensure_logged_in, except: [:qunit]
|
|
|
|
before_action :ensure_admin, except: [:qunit]
|
2016-08-26 01:14:56 +08:00
|
|
|
|
2017-08-31 12:06:56 +08:00
|
|
|
skip_before_action :check_xhr, :preload_json
|
2016-08-26 01:14:56 +08:00
|
|
|
|
|
|
|
layout false
|
|
|
|
|
|
|
|
def index
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
2016-09-10 04:51:07 +08:00
|
|
|
wizard = Wizard::Builder.new(current_user).build
|
2016-08-26 01:14:56 +08:00
|
|
|
render_serialized(wizard, WizardSerializer)
|
|
|
|
end
|
|
|
|
format.html {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def qunit
|
2017-07-27 23:29:18 +08:00
|
|
|
raise Discourse::InvalidAccess.new if Rails.env.production?
|
2016-08-26 01:14:56 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|