Sha256: 15ffb1d46be4be33d1ca143a0c64ecf9e35edb55e9be9bfb0a01889e46970bf1

Contents?: true

Size: 1.26 KB

Versions: 34

Compression:

Stored size: 1.26 KB

Contents

module Workarea
  class Storefront::ContentBlocksController < Storefront::ApplicationController
    layout 'workarea/storefront/empty'

    before_action :require_login
    before_action :require_admin
    before_action :disable_xss_protection

    def new
      @content = Content.find(params[:content_id])
      block = @content.blocks.build(type_id: params[:type_id])
      block.data = block.type.defaults
      @block = Storefront::ContentBlockViewModel.wrap(block, view_model_options)

      render :show
    end

    def show
      @content = Content.from_block(params[:id])
      block = @content.blocks.find(params[:id])

      @block = Storefront::ContentBlockViewModel.wrap(block, view_model_options)
    end

    def draft
      draft = Content::BlockDraft.find(params[:id])

      @content = draft.content
      @block = Storefront::ContentBlockViewModel.wrap(
        draft.to_block,
        view_model_options
      )

      render :show
    end

    private

    def require_admin
      unless current_admin.present?
        flash[:error] = 'You are not authorized to perform this action'
        redirect_to auth_failure_destination
        return false
      end
    end

    def disable_xss_protection
      response.headers['X-XSS-Protection'] = '0'
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-storefront-3.4.25 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.24 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.23 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.22 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.21 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.20 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.19 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.18 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.17 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.16 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.15 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.14 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.13 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.12 app/controllers/workarea/storefront/content_blocks_controller.rb