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.6 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.5 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.4 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.3 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.2 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.1 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.0 app/controllers/workarea/storefront/content_blocks_controller.rb
workarea-storefront-3.5.0.beta.1 app/controllers/workarea/storefront/content_blocks_controller.rb