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 => [:index, :show, :by_panel, :by_author]
7 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
8 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
28 @item = GroundColor.show(params[:id], @operators)
29 respond_to do |format|
34 format.json { render json: @item.to_json(GroundColor.show_json_opt) }
39 raise Pettanr::NotWork unless @operators.author.working_panel
40 @panel = Panel.edit(@operators.author.working_panel, @operators)
41 @ground_color = GroundColor.new :panel_id => @panel.id, :code => params[:code].to_i
42 @ground_color.supply_default
44 respond_to do |format|
46 format.json { render :json => @ground_color.to_json(GroundColor.show_json_opt) }
51 @ground_color = GroundColor.show(params[:id], @operators)
52 @panel = Panel.edit(@ground_color.panel.id, @operators)
54 respond_to do |format|
60 raise Pettanr::NotWork unless @operators.author.working_panel
61 @panel = Panel.edit(@operators.author.working_panel, @operators)
63 @ground_color = GroundColor.new
64 @ground_color.attributes = params[:ground_color]
65 @ground_color.overwrite @panel.id
67 respond_to do |format|
68 if @ground_color.valid?
69 if @ground_color.store @operators
70 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
71 format.html { redirect_to @panel }
72 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
74 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
75 format.html { render action: "new" }
76 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
79 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
80 format.html { render action: "new" }
81 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
87 @ground_color = GroundColor.show(params[:id], @operators)
88 @ground_color.attributes = params[:ground_color]
89 @panel = Panel.edit(@ground_color.panel.id, @operators)
90 @ground_color.overwrite @panel.id
92 respond_to do |format|
93 if @ground_color.store @operators
94 flash[:notice] = I18n.t('flash.notice.updated', :model => GroundColor.model_name.human)
95 format.html { redirect_to @ground_color }
96 format.json { head :ok }
98 flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundColor.model_name.human)
99 format.html { render action: "edit" }
100 format.json { render json: @ground_color.errors, status: :unprocessable_entity }
106 @ground_color = GroundColor.show(params[:id], @operators)
107 @panel = Panel.edit(@ground_color.panel.id, @operators)
109 respond_to do |format|
110 if @ground_color.remove @operators
111 flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundColor.model_name.human)
112 format.html { redirect_to @panel }
113 format.json { head :ok }
115 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundColor.model_name.human)
116 format.html { redirect_to @ground_color }
117 format.json { render json: @ground_color.errors, status: :unprocessable_entity }