OSDN Git Service

Merge branch 'v05' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v05client
[pettanr/pettanr.git] / app / controllers / provider_statuses_controller.rb
index e38c564..0e865e0 100644 (file)
@@ -1,7 +1,31 @@
 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]
+  
+  private
+  
+  def licenses_port
+    licenses = export_by('licenses_export', @provider_status, params[:date])
+    return nil unless licenses
+    ProviderLicense.import @provider_status.provider.id, licenses
+  end
+  
+  def artists_port
+    artists = export_by('artists_export', @provider_status, params[:date])
+    return nil unless artists
+    ProviderArtist.import @provider_status.provider.id, artists
+  end
+  
+  def original_pictures_port
+    original_pictures = export_by('original_pictures_export', @provider_status, params[:date])
+    return nil unless original_pictures
+    pictures = export_by('pictures_export', @provider_status, params[:date])
+    return nil unless pictures
+    ProviderOriginalPicture.import @provider_status.provider.id, original_pictures, pictures
+  end
+  
+  public
+  
   def index
     @page = ProviderStatus.page params[:page]
     @page_size = ProviderStatus.page_size params[:page_size]
@@ -65,4 +89,35 @@ class ProviderStatusesController < ApplicationController
       end
     end
   end
+  
+  def licenses_import
+    @provider_status = ProviderStatus.show(params[:id], @admin)
+    raise ActiveRecord::Forbidden if @provider_status.status == 0
+    @failures = licenses_port
+    respond_to do |format|
+      format.html # show.html.erb
+      format.json { render :json => @failures.to_json() }
+    end
+  end
+  
+  def artists_import
+    @provider_status = ProviderStatus.show(params[:id], @admin)
+    raise ActiveRecord::Forbidden if @provider_status.status == 0
+    @failures = artists_port
+    respond_to do |format|
+      format.html # show.html.erb
+      format.json { render :json => @failures.to_json() }
+    end
+  end
+  
+  def original_pictures_import
+    @provider_status = ProviderStatus.show(params[:id], @admin)
+    raise ActiveRecord::Forbidden if @provider_status.status == 0
+    @failures = original_pictures_port
+    respond_to do |format|
+      format.html # show.html.erb
+      format.json { render :json => @failures.to_json() }
+    end
+  end
+  
 end