Class: Admin::YandexMarketSettingsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/yandex_market_settings_controller.rb

Instance Method Summary collapse

Instance Method Details

#currencyObject



13
14
# File 'app/controllers/admin/yandex_market_settings_controller.rb', line 13

def currency
end

#export_filesObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/admin/yandex_market_settings_controller.rb', line 20

def export_files
  directory = File.join(Rails.root, 'public', 'yandex_market', '**', '*')
  # нельзя вызывать стат, не удостоверившись в наличии файла!!111
  @export_files =  Dir[directory].map {|x| [File.basename(x), (File.file?(x) ? File.mtime(x) : 0)] }.
    sort{|x,y| y.last <=> x.last }
  e = @export_files.find {|x| x.first == "yandex_market.xml" }
  @export_files.reject! {|x| x.first == "yandex_market.xml" }
  @export_files.unshift(e) unless e.blank?
end

#generalObject



9
10
11
# File 'app/controllers/admin/yandex_market_settings_controller.rb', line 9

def general
  @taxons =  Taxon.roots
end

#run_exportObject



30
31
32
33
34
35
36
37
# File 'app/controllers/admin/yandex_market_settings_controller.rb', line 30

def run_export
  command = %{cd #{Rails.root} && RAILS_ENV=#{Rails.env} rake spree_yandex_market:generate_ym &}
  logger.info "[ yandex market ] Запуск формирование файла экспорта из блока администрирования "
  logger.info "[ yandex market ] команда - #{command} "
  system command
  flash[:notice] = "Обновите страницу через несколько минут."
  redirect_to export_files_admin_yandex_market_settings_url
end

#showObject



5
6
7
# File 'app/controllers/admin/yandex_market_settings_controller.rb', line 5

def show
  @taxons =  Taxon.roots
end

#updateObject



39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/admin/yandex_market_settings_controller.rb', line 39

def update
  @config.attributes = params[:preferences]
  @config.save!
  
  respond_to do |format|
    format.html {
      redirect_to admin_yandex_market_settings_path
    }
  end
end

#ware_propertyObject



16
17
18
# File 'app/controllers/admin/yandex_market_settings_controller.rb', line 16

def ware_property
  @properties = Property.all
end