1 class DemanderStatusesController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy]
6 @page = DemanderStatus.page params[:page]
7 @page_size = DemanderStatus.page_size params[:page_size]
9 @demander_statuses = if @hide.blank?
10 DemanderStatus.list(@page, @page_size)
12 DemanderStatus.requested_list(@page, @page_size)
15 respond_to do |format|
16 format.html # index.html.erb
17 format.json { render :json => @demander_statuses.to_json(DemanderStatus.list_json_opt) }
22 @demander_status = DemanderStatus.show(params[:id], @admin)
24 respond_to do |format|
25 format.html # show.html.erb
26 format.json { render :json => @demander_status.to_json(DemanderStatus.show_json_opt) }
31 @demander_status = DemanderStatus.edit(params[:id], @admin)
32 respond_to do |format|
38 @demander_status = DemanderStatus.edit(params[:id], @admin)
39 respond_to do |format|
40 if @demander_status.approve params[:demander_status][:receive_hour1], params[:demander_status][:receive_hour2]
41 flash[:notice] = I18n.t('demander_statuses.flash.notice.approved')
42 format.html { redirect_to @demander_status }
43 format.json { head :ok }
45 format.html { render action: "edit" }
46 format.json { render json: @demander_status.errors, status: :unprocessable_entity }
52 @demander_status = DemanderStatus.edit(params[:id], @admin)
53 respond_to do |format|
54 if @demander_status.reject
55 flash[:notice] = I18n.t('demander_statuses.flash.notice.rejected')
56 format.html { redirect_to @demander_status }
57 format.json { head :ok }
59 flash[:notice] = I18n.t('demander_statuses.flash.notice.not_rejected')
60 format.html { redirect_to @demander_status }
61 format.json { render json: @demander_status.errors, status: :unprocessable_entity }