Sha256: beec415579a1c8e67f28d8370b1221d349c5c1b36c6d37d657fd74d3d6ae330b

Contents?: true

Size: 1.3 KB

Versions: 28

Compression:

Stored size: 1.3 KB

Contents

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

    skip_around_action :apply_segments
    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

28 entries across 28 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.26 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.25 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.23 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.22 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.21 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.20 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.19 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.18 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.17 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.16 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.15 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.14 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.13 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.12 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.11 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.10 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.9 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.8 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.7 app/controllers/workarea/storefront/content_blocks_controller.rb