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]
8 licenses = export_by('licenses_export', @provider_status, params[:date])
9 return nil unless licenses
10 ProviderLicense.import @provider_status.provider.id, licenses
14 artists = export_by('artists_export', @provider_status, params[:date])
15 return nil unless artists
16 ProviderArtist.import @provider_status.provider.id, artists
19 def original_pictures_port
20 original_pictures = export_by('original_pictures_export', @provider_status, params[:date])
21 return nil unless original_pictures
22 pictures = export_by('pictures_export', @provider_status, params[:date])
23 return nil unless pictures
24 ProviderOriginalPicture.import @provider_status.provider.id, original_pictures, pictures
30 @page = ProviderStatus.page params[:page]
31 @page_size = ProviderStatus.page_size params[:page_size]
33 @provider_statuses = if @hide.blank?
34 ProviderStatus.list(@page, @page_size)
36 ProviderStatus.available_list(@page, @page_size)
39 respond_to do |format|
40 format.html # index.html.erb
41 format.json { render :json => @provider_statuses.to_json(ProviderStatus.list_json_opt) }
46 @provider_status = ProviderStatus.show(params[:id], @admin)
48 respond_to do |format|
49 format.html # show.html.erb
50 format.json { render :json => @provider_status.to_json(ProviderStatus.show_json_opt) }
55 @provider_status = ProviderStatus.edit(params[:id], @admin)
56 respond_to do |format|
63 @provider_status = ProviderStatus.edit(params[:id], @admin)
64 @provider_status.attributes = params[:provider_status]
65 @provider_status.overwrite
66 respond_to do |format|
67 if @provider_status.save
68 flash[:notice] = I18n.t('provider_statuses.flash.notice.created')
69 format.html { redirect_to @provider_status }
70 format.json { head :ok }
72 format.html { render action: "edit" }
73 format.json { render json: @provider_status.errors, status: :unprocessable_entity }
79 @provider_status = ProviderStatus.edit(params[:id], @admin)
80 respond_to do |format|
81 if @provider_status.stop
82 flash[:notice] = I18n.t('provider_statuses.flash.notice.stopped')
83 format.html { redirect_to provider_statuses_url }
84 format.json { head :ok }
86 flash[:notice] = I18n.t('provider_statuses.flash.notice.not_stopped')
87 format.html { render action: "edit" }
88 format.json { render json: @provider_status.errors, status: :unprocessable_entity }
94 @provider_status = ProviderStatus.show(params[:id], @admin)
95 raise ActiveRecord::Forbidden if @provider_status.status == 0
96 @failures = licenses_port
97 respond_to do |format|
98 format.html # show.html.erb
99 format.json { render :json => @failures.to_json() }
104 @provider_status = ProviderStatus.show(params[:id], @admin)
105 raise ActiveRecord::Forbidden if @provider_status.status == 0
106 @failures = artists_port
107 respond_to do |format|
108 format.html # show.html.erb
109 format.json { render :json => @failures.to_json() }
113 def original_pictures_import
114 @provider_status = ProviderStatus.show(params[:id], @admin)
115 raise ActiveRecord::Forbidden if @provider_status.status == 0
116 @failures = original_pictures_port
117 respond_to do |format|
118 format.html # show.html.erb
119 format.json { render :json => @failures.to_json() }