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.45 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.44 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.43 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.42 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.41 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.40 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.39 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.38 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.37 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.36 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.35 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.34 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.33 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.32 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.31 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.30 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.29 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.28 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.27 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.4.26 app/controllers/workarea/storefront/content_blocks_controller.rb