1 class ProviderStatusesController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all]
6 @page = ProviderStatus.page params[:page]
7 @page_size = ProviderStatus.page_size params[:page_size]
9 @provider_statuses = if @hide.blank?
10 ProviderStatus.list(@page, @page_size)
12 ProviderStatus.available_list(@page, @page_size)
15 respond_to do |format|
16 format.html # index.html.erb
17 format.json { render :json => @provider_statuses.to_json(ProviderStatus.list_json_opt) }
22 @provider_status = ProviderStatus.show(params[:id], @admin)
24 respond_to do |format|
25 format.html # show.html.erb
26 format.json { render :json => @provider_status.to_json(ProviderStatus.show_json_opt) }
31 @provider_status = ProviderStatus.edit(params[:id], @admin)
32 respond_to do |format|
39 @provider_status = ProviderStatus.edit(params[:id], @admin)
40 @provider_status.attributes = params[:provider_status]
41 @provider_status.overwrite
42 respond_to do |format|
43 if @provider_status.save
44 flash[:notice] = I18n.t('provider_statuses.flash.notice.created')
45 format.html { redirect_to @provider_status }
46 format.json { head :ok }
48 format.html { render action: "edit" }
49 format.json { render json: @provider_status.errors, status: :unprocessable_entity }
55 @provider_status = ProviderStatus.edit(params[:id], @admin)
56 respond_to do |format|
57 if @provider_status.stop
58 flash[:notice] = I18n.t('provider_statuses.flash.notice.stopped')
59 format.html { redirect_to provider_statuses_url }
60 format.json { head :ok }
62 flash[:notice] = I18n.t('provider_statuses.flash.notice.not_stopped')
63 format.html { render action: "edit" }
64 format.json { render json: @provider_status.errors, status: :unprocessable_entity }
70 @provider_status = ProviderStatus.show(params[:id], @admin)
71 raise ActiveRecord::Forbidden if @provider_status.status == 0
72 @import_result = @provider_status.licenses_import params[:date]
73 respond_to do |format|
74 format.html # show.html.erb
75 format.json { render :json => @import_result.to_json() }
80 @provider_status = ProviderStatus.show(params[:id], @admin)
81 raise ActiveRecord::Forbidden if @provider_status.status == 0
82 @import_result = @provider_status.artists_import params[:date]
83 respond_to do |format|
84 format.html # show.html.erb
85 format.json { render :json => @import_result.to_json() }
89 def original_pictures_import
90 @provider_status = ProviderStatus.show(params[:id], @admin)
91 raise ActiveRecord::Forbidden if @provider_status.status == 0
92 @import_result = @provider_status.original_pictures_import params[:date]
93 respond_to do |format|
94 format.html # show.html.erb
95 format.json { render :json => @import_result.to_json() }
100 @provider_status = ProviderStatus.show(params[:id], @admin)
101 raise ActiveRecord::Forbidden if @provider_status.status == 0
102 @import_result = @provider_status.import params[:date]
103 respond_to do |format|
104 format.html # show.html.erb
105 format.json { render :json => @failures.to_json() }
110 ProviderStatus.approve_list.each do |provider_status|
111 @provider_status = provider_status params[:date]
113 respond_to do |format|
114 format.html { render :text => 'ok'}
115 format.json { render :json => {}.to_json() }