1 class ProviderStatusesController < ApplicationController
2 before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all]
5 @page = ProviderStatus.page params[:page]
6 @page_size = ProviderStatus.page_size params[:page_size]
8 @provider_statuses = if @hide.blank?
9 ProviderStatus.list(@page, @page_size)
11 ProviderStatus.available_list(@page, @page_size)
14 respond_to do |format|
15 format.html # index.html.erb
16 format.json { render :json => @provider_statuses.to_json(ProviderStatus.list_json_opt) }
21 @provider_status = ProviderStatus.show(params[:id], @admin)
23 respond_to do |format|
24 format.html # show.html.erb
25 format.json { render :json => @provider_status.to_json(ProviderStatus.show_json_opt) }
30 @provider_status = ProviderStatus.edit(params[:id], @admin)
31 respond_to do |format|
38 @provider_status = ProviderStatus.edit(params[:id], @admin)
39 @provider_status.attributes = params[:provider_status]
40 @provider_status.overwrite
41 respond_to do |format|
42 if @provider_status.save
43 flash[:notice] = I18n.t('provider_statuses.flash.notice.created')
44 format.html { redirect_to @provider_status }
45 format.json { head :ok }
47 format.html { render action: "edit" }
48 format.json { render json: @provider_status.errors, status: :unprocessable_entity }
54 @provider_status = ProviderStatus.edit(params[:id], @admin)
55 respond_to do |format|
56 if @provider_status.stop
57 flash[:notice] = I18n.t('provider_statuses.flash.notice.stopped')
58 format.html { redirect_to provider_statuses_url }
59 format.json { head :ok }
61 flash[:notice] = I18n.t('provider_statuses.flash.notice.not_stopped')
62 format.html { render action: "edit" }
63 format.json { render json: @provider_status.errors, status: :unprocessable_entity }
69 @provider_status = ProviderStatus.show(params[:id], @admin)
70 raise ActiveRecord::Forbidden if @provider_status.status == 0
71 @import_result = @provider_status.licenses_import params[:date]
72 respond_to do |format|
73 format.html # show.html.erb
74 format.json { render :json => @import_result.to_json() }
79 @provider_status = ProviderStatus.show(params[:id], @admin)
80 raise ActiveRecord::Forbidden if @provider_status.status == 0
81 @import_result = @provider_status.artists_import params[:date]
82 respond_to do |format|
83 format.html # show.html.erb
84 format.json { render :json => @import_result.to_json() }
88 def original_pictures_import
89 @provider_status = ProviderStatus.show(params[:id], @admin)
90 raise ActiveRecord::Forbidden if @provider_status.status == 0
91 @import_result = @provider_status.original_pictures_import params[:date]
92 respond_to do |format|
93 format.html # show.html.erb
94 format.json { render :json => @import_result.to_json() }
99 @provider_status = ProviderStatus.show(params[:id], @admin)
100 raise ActiveRecord::Forbidden if @provider_status.status == 0
101 @import_result = @provider_status.import params[:date]
102 respond_to do |format|
103 format.html # show.html.erb
104 format.json { render :json => @failures.to_json() }
109 ProviderStatus.approve_list.each do |provider_status|
110 @provider_status = provider_status params[:date]
112 respond_to do |format|
113 format.html { render :text => 'ok'}
114 format.json { render :json => {}.to_json() }