Sha256: 6b28d5dbac4d39e9c87bbd21444e3b897781ba997249ee1720cfea486eee216b

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module Workarea
  module Admin
    module Afterpay
      class ConfigurationsController < Admin::ApplicationController
        required_permissions :settings

        def edit
          @configuration = configuration
        end

        def update
          if configuration.update_attributes(configuration_params)
            redirect_to admin.edit_afterpay_configuration_path, flash: { success: t('workarea.admin.afterpay_configuration.edit.flash_messages.updated') }
          else
            flash[:error] = t('workarea.admin.afterpay_configuration.edit.flash_messages.save_error')
            @configuration = configuration
            render :edit, status: :unprocessable_entity
          end
        end

        private
          def configuration
            model = Workarea::Afterpay::Configuration.current
            Workarea::Admin::AfterpayConfigurationViewModel.new(model)
          end

          def configuration_params
            params.permit(:enabled, :display_on_cart, :display_on_pdp)
          end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-afterpay-2.1.2 app/controllers/workarea/admin/afterpay/configurations_controller.rb
workarea-afterpay-2.1.1 app/controllers/workarea/admin/afterpay/configurations_controller.rb
workarea-afterpay-2.1.0 app/controllers/workarea/admin/afterpay/configurations_controller.rb
workarea-afterpay-2.0.2 app/controllers/workarea/admin/afterpay/configurations_controller.rb