Sha256: c5ece361a75fd669e80f05e05085dea8c75247843d3a2ce8ea86fb6a4abc16ff

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module Gemgento
  class SyncController < ApplicationController
    before_filter :ensure_no_active_product_sync, :except => [:busy, :orders, :everything]
    before_filter :ensure_no_active_order_sync, :except => [:busy, :products, :everything]

    def products
      Sync.categories
      Sync.attributes
      Sync.products
      Sync.inventory
      render :nothing => true
    end

    def orders
      Sync.customers
      Sync.orders
      render :nothing => true
    end

    def everything
      Sync.everything
      render :nothing => true
    end

    def busy
      render :nothing => true
    end

    private

    def ensure_no_active_product_sync
      if Sync.is_active? %w[categories attributes products inventory everything]
        redirect_to '/sync/busy'
      end
    end

    def ensure_no_active_order_sync
      if Sync.is_active? %w[customers orders everything]
        redirect_to '/sync/busy'
      end
    end

    def ensure_no_active_sync
      if Sync.is_active?
        redirect_to '/sync/busy'
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/controllers/gemgento/sync_controller.rb