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.27 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.45 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.44 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.43 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.42 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.41 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.40 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.39 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.38 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/categorizations_controller.rb
workarea-admin-3.4.37 app/controllers/workarea/admin/categorizations_controller.rb