Sha256: 0cb31b9bdfb8d5be3f7ea84ba1ddaa892675d6fec3f56a255e7aed543715357e

Contents?: true

Size: 1009 Bytes

Versions: 62

Compression:

Stored size: 1009 Bytes

Contents

module Workarea
  module Admin
    class CategorizationsController < Admin::ApplicationController
      required_permissions :catalog

      before_action :check_publishing_authorization
      before_action :find_product

      def index
      end

      def create
        Catalog::Category.in(id: params[:category_ids]).each do |category|
          category.add_product(@product.id)
        end

        flash[:success] = t('workarea.admin.categorizations.flash_messages.added')
        redirect_to catalog_product_categorizations_path(@product)
      end

      def destroy
        category = Catalog::Category.find_by(slug: params[:id])
        category.remove_product(@product.id)

        flash[:success] = t('workarea.admin.categorizations.flash_messages.removed')
        head :ok
      end

      private

      def find_product
        model = Catalog::Product.find_by(slug: params[:catalog_product_id])
        @product = ProductViewModel.new(model, view_model_options)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.15 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.36 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.35 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.34 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.33 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.32 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.31 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.30 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.29 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.6 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.28 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.5 app/controllers/workarea/admin/categorizations_controller.rb