1
0
Fork 0

FIX: extension module prepending

Dieser Commit ist enthalten in:
Angus McLeod 2019-12-12 10:53:13 +11:00
Ursprung 6ad44d58ad
Commit e584123d34
5 geänderte Dateien mit 42 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -1,9 +1,11 @@
module ApplicationControllerCWExtension module CustomWizardApplicationControllerExtension
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do def self.prepended(klass)
klass.class_eval do
before_action :redirect_to_wizard_if_required, if: :current_user before_action :redirect_to_wizard_if_required, if: :current_user
end end
end
def redirect_to_wizard_if_required def redirect_to_wizard_if_required
wizard_id = current_user.custom_fields['redirect_to_wizard'] wizard_id = current_user.custom_fields['redirect_to_wizard']
@ -23,5 +25,5 @@ module ApplicationControllerCWExtension
end end
class ApplicationController class ApplicationController
prepend ApplicationControllerCWExtension if SiteSetting.custom_wizard_enabled prepend CustomWizardApplicationControllerExtension if SiteSetting.custom_wizard_enabled
end end

Datei anzeigen

@ -1,11 +1,12 @@
## TODO limit this to the first admin ## TODO limit this to the first admin
module SiteSerializerCWX module CustomWizardSiteSerializerExtension
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do def self.prepended(klass)
klass.class_eval do
attributes :complete_custom_wizard attributes :complete_custom_wizard
end end
end
def include_wizard_required? def include_wizard_required?
scope.is_admin? && Wizard.new(scope.user).requires_completion? scope.is_admin? && Wizard.new(scope.user).requires_completion?
@ -23,5 +24,5 @@ module SiteSerializerCWX
end end
class SiteSerializer class SiteSerializer
prepend SiteSerializerCWX if SiteSetting.custom_wizard_enabled prepend CustomWizardSiteSerializerExtension if SiteSetting.custom_wizard_enabled
end end

Datei anzeigen

@ -1,9 +1,11 @@
module CustomWizardWizardFieldSerializerExtension module CustomWizardFieldSerializerExtension
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do def self.prepended(klass)
klass.class_eval do
attributes :dropdown_none, :image, :file_types, :limit, :property attributes :dropdown_none, :image, :file_types, :limit, :property
end end
end
def label def label
return object.label if object.label.present? return object.label if object.label.present?
@ -45,5 +47,5 @@ module CustomWizardWizardFieldSerializerExtension
end end
class WizardFieldSerializer class WizardFieldSerializer
prepend CustomWizardWizardFieldSerializerExtension if SiteSetting.custom_wizard_enabled prepend CustomWizardFieldSerializerExtension if SiteSetting.custom_wizard_enabled
end end

Datei anzeigen

@ -1,7 +1,8 @@
module CustomWizardWizardSerializerExtension module CustomWizardSerializerExtension
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do def self.prepended(klass)
klass.class_eval do
attributes :id, attributes :id,
:name, :name,
:background, :background,
@ -13,6 +14,7 @@ module CustomWizardWizardSerializerExtension
:categories, :categories,
:uncategorized_category_id :uncategorized_category_id
end end
end
def id def id
object.id object.id
@ -89,7 +91,7 @@ module CustomWizardWizardSerializerExtension
site = ::Site.new(scope) site = ::Site.new(scope)
::ActiveModel::ArraySerializer.new(site.categories, each_serializer: BasicCategorySerializer) ::ActiveModel::ArraySerializer.new(site.categories, each_serializer: BasicCategorySerializer)
rescue => e rescue => e
puts "HERE IS THE ERROR: #{e.inspect}" []
end end
end end
@ -99,5 +101,5 @@ module CustomWizardWizardSerializerExtension
end end
class WizardSerializer class WizardSerializer
prepend CustomWizardWizardSerializerExtension if SiteSetting.custom_wizard_enabled prepend CustomWizardSerializerExtension if SiteSetting.custom_wizard_enabled
end end

Datei anzeigen

@ -1,9 +1,11 @@
module CustomWizardWizardStepSerializerExtension module CustomWizardStepSerializerExtension
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do def self.prepended(klass)
klass.class_eval do
attributes :permitted, :permitted_message attributes :permitted, :permitted_message
end end
end
def title def title
return PrettyText.cook(object.title) if object.title return PrettyText.cook(object.title) if object.title
@ -25,5 +27,5 @@ module CustomWizardWizardStepSerializerExtension
end end
class WizardStepSerializer class WizardStepSerializer
prepend CustomWizardWizardStepSerializerExtension if SiteSetting.custom_wizard_enabled prepend CustomWizardStepSerializerExtension if SiteSetting.custom_wizard_enabled
end end