1 class GroundColorsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
5 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
7 before_filter :authenticate_reader, :only => [:index, :show, :by_panel, :by_author]
8 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
9 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
29 @item = GroundColor.show(params[:id], @operators)
30 respond_to do |format|
35 format.json { render json: @item.to_json(GroundColor.show_json_opt) }
40 raise Pettanr::NotWork unless @operators.author.working_panel
41 @panel = Panel.edit(@operators.author.working_panel, @operators)
42 @ground_color = GroundColor.new :panel_id => @panel.id, :code => params[:code].to_i
43 @ground_color.supply_default
45 respond_to do |format|
47 format.json { render :json => @ground_color.to_json(GroundColor.show_json_opt) }
52 @ground_color = GroundColor.show(params[:id], @operators)
53 @panel = Panel.edit(@ground_color.panel.id, @operators)
55 respond_to do |format|
61 raise Pettanr::NotWork unless @operators.author.working_panel
62 @panel = Panel.edit(@operators.author.working_panel, @operators)
64 @ground_color = GroundColor.new
65 @ground_color.attributes = params[:ground_color]
66 @ground_color.overwrite @panel.id
68 respond_to do |format|
69 if @ground_color.valid?
70 if @ground_color.store @operators
71 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
72 format.html { redirect_to @panel }
73 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
75 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
76 format.html { render action: "new" }
77 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
80 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
81 format.html { render action: "new" }
82 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
88 @ground_color = GroundColor.show(params[:id], @operators)
89 @ground_color.attributes = params[:ground_color]
90 @panel = Panel.edit(@ground_color.panel.id, @operators)
91 @ground_color.overwrite @panel.id
93 respond_to do |format|
94 if @ground_color.store @operators
95 flash[:notice] = I18n.t('flash.notice.updated', :model => GroundColor.model_name.human)
96 format.html { redirect_to @ground_color }
97 format.json { head :ok }
99 flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundColor.model_name.human)
100 format.html { render action: "edit" }
101 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
107 @ground_color = GroundColor.show(params[:id], @operators)
108 @panel = Panel.edit(@ground_color.panel.id, @operators)
110 respond_to do |format|
111 if @ground_color.remove @operators
112 flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundColor.model_name.human)
113 format.html { redirect_to @panel }
114 format.json { head :ok }
116 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundColor.model_name.human)
117 format.html { redirect_to @ground_color }
118 format.json { render json: @ground_color.errors, status: :unprocessable_entity }