class ProviderStatusesController < ApplicationController
- layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy]
-
+ before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all]
+
def index
@page = ProviderStatus.page params[:page]
@page_size = ProviderStatus.page_size params[:page_size]
@provider_status.overwrite
respond_to do |format|
if @provider_status.save
- format.html { redirect_to @provider_status, notice: 'ProviderStatus was successfully updated.' }
+ flash[:notice] = I18n.t('provider_statuses.flash.notice.created')
+ format.html { redirect_to @provider_status }
format.json { head :ok }
else
format.html { render action: "edit" }
def destroy
@provider_status = ProviderStatus.edit(params[:id], @admin)
- @provider_status.destroy
respond_to do |format|
- format.html { redirect_to comics_url }
- format.json { head :ok }
+ if @provider_status.stop
+ flash[:notice] = I18n.t('provider_statuses.flash.notice.stopped')
+ format.html { redirect_to provider_statuses_url }
+ format.json { head :ok }
+ else
+ flash[:notice] = I18n.t('provider_statuses.flash.notice.not_stopped')
+ format.html { render action: "edit" }
+ format.json { render json: @provider_status.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ def licenses_import
+ @provider_status = ProviderStatus.show(params[:id], @admin)
+ raise ActiveRecord::Forbidden if @provider_status.status == 0
+ @import_result = @provider_status.licenses_import params[:date]
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render :json => @import_result.to_json() }
+ end
+ end
+
+ def artists_import
+ @provider_status = ProviderStatus.show(params[:id], @admin)
+ raise ActiveRecord::Forbidden if @provider_status.status == 0
+ @import_result = @provider_status.artists_import params[:date]
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render :json => @import_result.to_json() }
+ end
+ end
+
+ def original_pictures_import
+ @provider_status = ProviderStatus.show(params[:id], @admin)
+ raise ActiveRecord::Forbidden if @provider_status.status == 0
+ @import_result = @provider_status.original_pictures_import params[:date]
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render :json => @import_result.to_json() }
+ end
+ end
+
+ def import
+ @provider_status = ProviderStatus.show(params[:id], @admin)
+ raise ActiveRecord::Forbidden if @provider_status.status == 0
+ @import_result = @provider_status.import params[:date]
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render :json => @failures.to_json() }
+ end
+ end
+
+ def import_all
+ ProviderStatus.approve_list.each do |provider_status|
+ @provider_status = provider_status params[:date]
+ end
+ respond_to do |format|
+ format.html { render :text => 'ok'}
+ format.json { render :json => {}.to_json() }
end
end
+
end