class ProviderStatusesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
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]
def licenses_import
@provider_status = ProviderStatus.show(params[:id], @admin)
raise ActiveRecord::Forbidden if @provider_status.status == 0
- t = ymd_to_time params[:date]
- url = export_url @provider_status.provider.demander_url, 'licenses_export', @provider_status.token, t
- @failures = ProviderLicense.import @provider_status.provider.id, export_from_provider(url)
+ @failures = licenses_port
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @failures.to_json() }
def artists_import
@provider_status = ProviderStatus.show(params[:id], @admin)
raise ActiveRecord::Forbidden if @provider_status.status == 0
- t = ymd_to_time params[:date]
- url = export_url @provider_status.provider.demander_url, 'artists_export', @provider_status.token, t
- @failures = ProviderArtist.import @provider_status.provider.id, export_from_provider(url)
+ @failures = artists_port
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @failures.to_json() }
def original_pictures_import
@provider_status = ProviderStatus.show(params[:id], @admin)
raise ActiveRecord::Forbidden if @provider_status.status == 0
- original_pictures = export_by('original_pictures_export', @provider_status, params[:date])
- pictures = export_by('pictures_export', @provider_status, params[:date])
- @failures = ProviderOriginalPicture.import @provider_status.provider.id, original_pictures, pictures
+ @failures = original_pictures_port
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @failures.to_json() }