1 class ProviderStatusesController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import]
6 @page = ProviderStatus.page params[:page]
7 @page_size = ProviderStatus.page_size params[:page_size]
9 @provider_statuses = if @hide.blank?
10 ProviderStatus.list(@page, @page_size)
12 ProviderStatus.available_list(@page, @page_size)
15 respond_to do |format|
16 format.html # index.html.erb
17 format.json { render :json => @provider_statuses.to_json(ProviderStatus.list_json_opt) }
22 @provider_status = ProviderStatus.show(params[:id], @admin)
24 respond_to do |format|
25 format.html # show.html.erb
26 format.json { render :json => @provider_status.to_json(ProviderStatus.show_json_opt) }
31 @provider_status = ProviderStatus.edit(params[:id], @admin)
32 respond_to do |format|
39 @provider_status = ProviderStatus.edit(params[:id], @admin)
40 @provider_status.attributes = params[:provider_status]
41 @provider_status.overwrite
42 respond_to do |format|
43 if @provider_status.save
44 format.html { redirect_to @provider_status, notice: 'ProviderStatus was successfully updated.' }
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 @provider_status.destroy
56 respond_to do |format|
57 format.html { redirect_to comics_url }
58 format.json { head :ok }
63 @provider_status = ProviderStatus.show(params[:id], @admin)
64 raise ActiveRecord::Forbidden if @provider_status.status == 0
65 t = ymd_to_time params[:date]
66 url = export_url @provider_status.provider.demander_url, @provider_status.token, t
67 @failures = ProviderLicense.import @provider_status.provider.id, export_from_provider(url)
68 respond_to do |format|
69 format.html # show.html.erb
70 format.json { render :json => @provider_status.to_json(ProviderStatus.show_json_opt) }