2019-12-05 09:05:21 +01:00
|
|
|
## TODO limit this to the first admin
|
2019-12-12 05:43:11 +01:00
|
|
|
|
2019-12-12 00:53:13 +01:00
|
|
|
module CustomWizardSiteSerializerExtension
|
2019-12-06 10:05:19 +01:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2019-12-12 00:53:13 +01:00
|
|
|
def self.prepended(klass)
|
|
|
|
klass.class_eval do
|
|
|
|
attributes :complete_custom_wizard
|
|
|
|
end
|
2019-12-06 10:05:19 +01:00
|
|
|
end
|
2019-12-05 09:05:21 +01:00
|
|
|
|
|
|
|
def include_wizard_required?
|
|
|
|
scope.is_admin? && Wizard.new(scope.user).requires_completion?
|
|
|
|
end
|
|
|
|
|
|
|
|
def complete_custom_wizard
|
|
|
|
if scope.user && requires_completion = CustomWizard::Wizard.prompt_completion(scope.user)
|
2020-04-14 07:46:06 +02:00
|
|
|
requires_completion.map {|w| { name: w[:name], url: "/w/#{w[:id]}"} }
|
2019-12-05 09:05:21 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_complete_custom_wizard?
|
|
|
|
complete_custom_wizard.present?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-12 05:43:11 +01:00
|
|
|
class ::SiteSerializer
|
2019-12-12 00:53:13 +01:00
|
|
|
prepend CustomWizardSiteSerializerExtension if SiteSetting.custom_wizard_enabled
|
2019-12-05 09:05:21 +01:00
|
|
|
end
|