1 class GroundColorsController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
9 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
29 def show_html_format format
37 respond_to do |format|
38 show_html_format format
39 show_prof_format format
40 show_json_format format
57 raise Pettanr::NotWork unless @operators.author.working_panel
58 @panel = Panel.edit(@operators.author.working_panel, @operators)
59 @ground_color = GroundColor.new :panel_id => @panel.id, :code => params[:code].to_i
60 @ground_color.supply_default
62 respond_to do |format|
64 format.json { render :json => @ground_color.to_json(GroundColor.show_json_opt) }
69 @ground_color = GroundColor.show(params[:id], @operators)
70 @panel = Panel.edit(@ground_color.panel.id, @operators)
72 respond_to do |format|
78 raise Pettanr::NotWork unless @operators.author.working_panel
79 @panel = Panel.edit(@operators.author.working_panel, @operators)
81 @ground_color = GroundColor.new
82 @ground_color.attributes = params[:ground_color]
83 @ground_color.overwrite @panel.id
85 respond_to do |format|
86 if @ground_color.valid?
87 if @ground_color.store @operators
88 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
89 format.html { redirect_to @panel }
90 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
92 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
93 format.html { render action: "new" }
94 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
97 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
98 format.html { render action: "new" }
99 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
105 @ground_color = GroundColor.show(params[:id], @operators)
106 @ground_color.attributes = params[:ground_color]
107 @panel = Panel.edit(@ground_color.panel.id, @operators)
108 @ground_color.overwrite @panel.id
110 respond_to do |format|
111 if @ground_color.store @operators
112 flash[:notice] = I18n.t('flash.notice.updated', :model => GroundColor.model_name.human)
113 format.html { redirect_to @ground_color }
114 format.json { head :ok }
116 flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundColor.model_name.human)
117 format.html { render action: "edit" }
118 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
124 @ground_color = GroundColor.show(params[:id], @operators)
125 @panel = Panel.edit(@ground_color.panel.id, @operators)
127 respond_to do |format|
128 if @ground_color.remove @operators
129 flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundColor.model_name.human)
130 format.html { redirect_to @panel }
131 format.json { head :ok }
133 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundColor.model_name.human)
134 format.html { redirect_to @ground_color }
135 format.json { render json: @ground_color.errors, status: :unprocessable_entity }