Sha256: abbb68147c5dff082ae045d6fe93c20c3e79ad0f36704cf2d263e6d11f3f2c6e

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

module Spree
  module Admin
    class GeneralSettingsController < Spree::Admin::BaseController
      include Spree::Backend::Callbacks

      before_action :set_store

      def edit
        @preferences_security = [:check_for_spree_alerts]
      end

      def update
        params.each do |name, value|
          next unless Spree::Config.has_preference? name
          Spree::Config[name] = value
        end

        current_store.update_attributes store_params

        flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:general_settings))
        redirect_to edit_admin_general_settings_path
      end

      def dismiss_alert
        if request.xhr? and params[:alert_id]
          dismissed = Spree::Config[:dismissed_spree_alerts] || ''
          Spree::Config.set dismissed_spree_alerts: dismissed.split(',').push(params[:alert_id]).join(',')
          filter_dismissed_alerts
          render nothing: true
        end
      end

      def clear_cache
        Rails.cache.clear
        invoke_callbacks(:clear_cache, :after)
        head :no_content
      end

      private
      def store_params
        params.require(:store).permit(permitted_store_attributes)
      end

      def set_store
        @store = current_store
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree_backend-3.0.4 app/controllers/spree/admin/general_settings_controller.rb
spree_backend-3.0.3 app/controllers/spree/admin/general_settings_controller.rb
spree_backend-3.0.2 app/controllers/spree/admin/general_settings_controller.rb
spree_backend-3.0.1 app/controllers/spree/admin/general_settings_controller.rb
spree_backend-3.0.0 app/controllers/spree/admin/general_settings_controller.rb
spree_backend-3.0.0.rc4 app/controllers/spree/admin/general_settings_controller.rb
spree_backend-3.0.0.rc3 app/controllers/spree/admin/general_settings_controller.rb